Joe Riel

9660 Reputation

23 Badges

20 years, 20 days

MaplePrimes Activity


These are replies submitted by Joe Riel

Note that I didn't check whether a solution was found or the loop terminated.  You can either add a flag in the loop, or use a counter and check whether it exceeded the "to" value. For example,

if n = 361 then error "no solution found" end if;

isolve does not necessarily find a solution.  You might try using msolve for various moduli and then selecting a common solution.  For example,

eq := 5*x^2+11*x*y-5*y^2=11:
sols := {seq({msolve(eq, ithprime(i))}, i=1..10)};
sols := select(type, sols, set(set(name=integer)));
`intersect`(sols[]);
                        {{x = 1, y = 1}}

The purpose of the select statement is to discard solutions that are not integers; for example, with a modulus of 5 the equation becomes x*y = 1.

A few alternatives,

restart:
m:=45;
for n to 360 while modp(n*m,360) <> 0 do end do;
n;

for n to 360 do
    if modp(n*m,360) = 0 then break; end if;
end do;
n;



A few alternatives,

restart:
m:=45;
for n to 360 while modp(n*m,360) <> 0 do end do;
n;

for n to 360 do
    if modp(n*m,360) = 0 then break; end if;
end do;
n;



I wish there were an easy answer.  More accurately, if you were familar with Emacs it probably wouldn't be difficult, however, Emacs has a rather long learning curve [whether it is steep or not depends on how one defines the curve].

Are you using a *nix system or Windows?  The former makes things easier.  You need to create/edit the emacs configuration file, which on a *nix system is generally ~/.emacs.   In mine, the section apropos to mapleV mode is

(autoload 'maplev-mode "maplev" "Maple editing mode" t)

;; add maplev-mode to auto-mode-alist so that files with extensions
;; .mtx and .mpl open in maplev-mode.

(setq 
 auto-mode-alist (cons (cons (concat "\\." (regexp-opt '("mtx" "mpl") t)
                     "$")
                 'maplev-mode)
               auto-mode-alist)
 maplev-copyright-owner "Joseph S. Riel"
 maplev-default-release "12"
 maplev-executable-alist 
 '(("12"  . ("maple12" nil "mint12"))
   ("11"  . ("maple11" nil "mint11"))
   ("10"  . ("maple10" nil "mint10"))
   ("9.5" . ("maple9.5" nil "mint9.5"))
   ("9"   . ("maple9" nil "mint9"))
   ("8"   . ("maple8" nil "mint8")))
 maplev-mint-query nil
 maplev-description-quote-char ?\"
 maplev-mint-include-dir "/home/joe/maple/lib/include"
 )

You'll want to modify those per your setup.  In particular, change maplev-copyright-owner to your name (that is used to insert copyright statements into your Maple code).  For now, leave maplev-default-release at 12, even though you have 13.  The reason for that is I haven't got around to uploading the latest maplev.el file that defines changes specific to maple13 (there are very few, so that won't be an issue). You will have to modify the assignment to maplev-executable-alist.  I use soft-links on my linux system so that maple12 points to the script that launches the maple12 (actually maple13) command line version.  You might do something like

(setq maplev-executable-alist '(("12" . ("/usr/local/maple/bin/maple" nil "usr/local/maple/bin/mint")))

That assumes your command line maple script is /usr/local/maple/bin/maple; use whatever is appropriate for your installation.

To see whether it works, fire up emacs open a file with extension .mpl.  That should invoke maplev mode.  If that works (my guess is that something will go wrong and require some hacking; just ask).

I wish there were an easy answer.  More accurately, if you were familar with Emacs it probably wouldn't be difficult, however, Emacs has a rather long learning curve [whether it is steep or not depends on how one defines the curve].

Are you using a *nix system or Windows?  The former makes things easier.  You need to create/edit the emacs configuration file, which on a *nix system is generally ~/.emacs.   In mine, the section apropos to mapleV mode is

(autoload 'maplev-mode "maplev" "Maple editing mode" t)

;; add maplev-mode to auto-mode-alist so that files with extensions
;; .mtx and .mpl open in maplev-mode.

(setq 
 auto-mode-alist (cons (cons (concat "\\." (regexp-opt '("mtx" "mpl") t)
                     "$")
                 'maplev-mode)
               auto-mode-alist)
 maplev-copyright-owner "Joseph S. Riel"
 maplev-default-release "12"
 maplev-executable-alist 
 '(("12"  . ("maple12" nil "mint12"))
   ("11"  . ("maple11" nil "mint11"))
   ("10"  . ("maple10" nil "mint10"))
   ("9.5" . ("maple9.5" nil "mint9.5"))
   ("9"   . ("maple9" nil "mint9"))
   ("8"   . ("maple8" nil "mint8")))
 maplev-mint-query nil
 maplev-description-quote-char ?\"
 maplev-mint-include-dir "/home/joe/maple/lib/include"
 )

You'll want to modify those per your setup.  In particular, change maplev-copyright-owner to your name (that is used to insert copyright statements into your Maple code).  For now, leave maplev-default-release at 12, even though you have 13.  The reason for that is I haven't got around to uploading the latest maplev.el file that defines changes specific to maple13 (there are very few, so that won't be an issue). You will have to modify the assignment to maplev-executable-alist.  I use soft-links on my linux system so that maple12 points to the script that launches the maple12 (actually maple13) command line version.  You might do something like

(setq maplev-executable-alist '(("12" . ("/usr/local/maple/bin/maple" nil "usr/local/maple/bin/mint")))

That assumes your command line maple script is /usr/local/maple/bin/maple; use whatever is appropriate for your installation.

To see whether it works, fire up emacs open a file with extension .mpl.  That should invoke maplev mode.  If that works (my guess is that something will go wrong and require some hacking; just ask).

This also works

NextZero(sin, 0);
NextZero(D(sin), 0);  

This also works

NextZero(sin, 0);
NextZero(D(sin), 0);  

Yes, plottools:-line is what you want to use. To improve the look I also used plottools:-circle to draw the mass. Use plots:-display to draw the actual plot.

restart;
ode := { diff(phi(t),t,t) = -phi(t)
         , D(phi)(0) = 0
         , phi(0) = Pi/4
       }:

integ := dsolve(ode, numeric):

f := proc(tt)
uses PT = plottools;
local pt;
    pt := eval([sin,-cos](phi(t)), integ(tt));
    plots:-display(PT:-circle(pt, 0.1), PT:-line([0,0],pt));
end proc:

plots:-animate(f
               , [t]
               , t=0..10
               , frames=100
               , scaling=constrained
               , view=[-1..1,-1..1]
               , symbol=circle
              );

Yes, plottools:-line is what you want to use. To improve the look I also used plottools:-circle to draw the mass. Use plots:-display to draw the actual plot.

restart;
ode := { diff(phi(t),t,t) = -phi(t)
         , D(phi)(0) = 0
         , phi(0) = Pi/4
       }:

integ := dsolve(ode, numeric):

f := proc(tt)
uses PT = plottools;
local pt;
    pt := eval([sin,-cos](phi(t)), integ(tt));
    plots:-display(PT:-circle(pt, 0.1), PT:-line([0,0],pt));
end proc:

plots:-animate(f
               , [t]
               , t=0..10
               , frames=100
               , scaling=constrained
               , view=[-1..1,-1..1]
               , symbol=circle
              );

MapleV R5 was a long time ago.  In the current version the animation viewer has buttons for playing the animation.  However, I vaguely recall that that was a later addition.  I'm guessing that there might be a button on the toolbar, rather than the viewer, that starts the animation. 

Try adding the option 'numpoints' = 200.  

It works on Maple 13, I see no reason it shouldn't work on a 10 year old release 8-).

It's not that the macros survive restart, but rather that they are expanded before anything is executed.  So

$define mymacro whatever
restart;
mymacro

is equivalent to

restart;
whatever

Just  to clarify, when a script is processed by tty Maple (cmaple), the preprocessor reads the entire script, expanding any macros as it goes. The output is then passed to the Maple interpreter (more or less).  I suppose (but don't know) that this is a pipelined process, so your interpretation (that the macros are cached) makes just as much sense.  The important point is that the Maple kernel (engine) does not directly interact with the preprocessor, so a restart has no effect.

It's not that the macros survive restart, but rather that they are expanded before anything is executed.  So

$define mymacro whatever
restart;
mymacro

is equivalent to

restart;
whatever

Just  to clarify, when a script is processed by tty Maple (cmaple), the preprocessor reads the entire script, expanding any macros as it goes. The output is then passed to the Maple interpreter (more or less).  I suppose (but don't know) that this is a pipelined process, so your interpretation (that the macros are cached) makes just as much sense.  The important point is that the Maple kernel (engine) does not directly interact with the preprocessor, so a restart has no effect.

Your procedures have problems. It is not immediately clear what they are supposed to do, so I'm not going to suggest a correction, however, I will explain the errors I see.

First off, assigning a Maple procedure doesn't execute it.  You have to call it to do something.  Maybe you do that elsewhere, but in the worksheet there are no calls to the procedures Y, B1, and B2.  A call to a procedure uses parenthese, not square brackes.  That is, you would do B1( ... )  to call procedure B1 with the an appropriate argument sequence (here shown as ... ).

Consider the assignment to Y

Y := proc (m) 
local i, B, A, Y;
global t; 
    Y[i] := [];
    for i from -2 to t+2 do
        Y[i] := (-Y[i+2]+Y[i+1]*(4-B[2*i-2]*(4-B[2*i-3])))/(6+A[i]-B[2*i-4]-B[2*i-1]*(4-B[2*i-3]));
        Y[i] := [op(Y[i], i)] 
    end do 
end proc:

The first executable statement in Y is the assignment

  Y[i] := []

While that is syntactically correct, and will do something, it probably doesn't do what you expect.  It merely assigns the empty list to the entry in a table Y with index i (a local variable).  What you probably want to do here is to initialize an Array, maybe with zero values. You could do that with

  Y := Array(-2..t+2);

Note that you are using a local variable named Y that matches the global variable Y, which is the procedure name. That is perfectly legal, however, it might not be a wise choice.  Maybe you should name the procedure CreateY, then there would be less confusion.

The body of loop references A and B, which are declared as local variables.  That probably is not what you want.  Maybe they should be global? Better yet, they probably should be parameters to this procedure.

The procedure doesn't explicitly return anything, which means that the return value is the last thing computed,  Here that would be whatever was assigned to Y[t+2].  Probably you want to return the Array Y.  That can be done by adding

  return Y

after the end of the loop. If you want a list as output you can convert it to a list, say convert(Y, list).

If I knew what you really intended I could probably give better suggestions...

First 118 119 120 121 122 123 124 Last Page 120 of 195