Doug Meade

 

Doug

---------------------------------------------------------------------
Douglas B. Meade <><
Math, USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Phone: (803) 777-6183 URL: http://www.math.sc.edu

MaplePrimes Activity


These are replies submitted by Doug Meade

I cannot confirm what you are reporting.

Here is how I tried to reproduce your experience.

  1. Open new Maple document (not worksheet) with 2D input
  2. Paste code from MaplePrimes into empty document (this is a 2D input region with no prompt)
  3. Press Enter [at this point the maplet launches]
  4. Play with maplet, then kill it
  5. Export document as maplet (File : Export As ...  : Maplet (.maplet))
  6. Double-click on .maplet file [again, the maplet lauches]
  7. Play with maplet, then kill it

Based on this, everything works fine. The only difference I see in the .maplet file created by these steps is everything is on one long line.

This is not the usual way in which I use Maple. I work with worksheets and 1D input (so I do see the prompt), or with text files.

To give you something specific to compare with, I am uploading the .mw files for the worksheet and document versions of the maplet - and the corresponding .maplet files: UniqueWkst.maplet and UniqueDoc.maplet .

If I have misinterpretted your report, please point out my error and I will see what I can do.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

The read "foo.maplet" works only if the maplet is in a known, fixed, and local location. The context menu option is interesting. I've not played much with this. Your comments suggest this feature is not yet as robust as it needs to be.

As I type this, I realize there might be a way to use the Sockets package to download a .maplet file to a temp folder, when can then be read.

All of this is rather complicated. Having this feature would be a benefit to many users. I'll end by asking that this functionality be (re)considered for upcoming releases.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

The read "foo.maplet" works only if the maplet is in a known, fixed, and local location. The context menu option is interesting. I've not played much with this. Your comments suggest this feature is not yet as robust as it needs to be.

As I type this, I realize there might be a way to use the Sockets package to download a .maplet file to a temp folder, when can then be read.

All of this is rather complicated. Having this feature would be a benefit to many users. I'll end by asking that this functionality be (re)considered for upcoming releases.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Maybe I misunderstood your initial request.

The amount of empty space in the menu bar depends on the size of your Maple window. It sounds as though you want a customizeable drop-down menu or button elsewhere at the top of the GUI. I don't know how to do this.

My suggestion is to insert a hyperlink in the worksheet whose target is a maplet. To simulate the menu bar suggestion, you could create a worksheet that put all of these hyperlinks in a row (table?) at the top of a worksheet.

The functionality I would like to have is the ability to insert an embedded component (button or combo box) whose action is to launch a maplet. To the best of my knowledge, this is not currently supported. I would love to be told I am wrong (about this).

Am I understanding your request?

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Maybe I misunderstood your initial request.

The amount of empty space in the menu bar depends on the size of your Maple window. It sounds as though you want a customizeable drop-down menu or button elsewhere at the top of the GUI. I don't know how to do this.

My suggestion is to insert a hyperlink in the worksheet whose target is a maplet. To simulate the menu bar suggestion, you could create a worksheet that put all of these hyperlinks in a row (table?) at the top of a worksheet.

The functionality I would like to have is the ability to insert an embedded component (button or combo box) whose action is to launch a maplet. To the best of my knowledge, this is not currently supported. I would love to be told I am wrong (about this).

Am I understanding your request?

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

While you don't give us any hint as to the nature of your function (of R), this example should illustrate how you can achieve your goal.

I start with Alec's myprint2 command:

myprint2:=x->printf("%s",StringTools:-SubstituteAll(
    sprintf("%{c\n}.4e",x),"e","d")):

Your inputs with non-integer increments can be constructed using the seq command:

S := [seq( R, R=1..2, 0.1 )];
            [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0]

The myprint2 command works best on a vector (not a list):

myprint2( Vector(S) );
1.0000d+00
1.1000d+00
1.2000d+00
1.3000d+00
1.4000d+00
1.5000d+00
1.6000d+00
1.7000d+00
1.8000d+00
1.9000d+00
2.0000d+00

To get the list of function values, use map or the newer elementwise operator (~):
 

f := R -> sin(R^2):

f~(S);
[sin(1), 0.9356160016, 0.9914583482, 0.9929036511, 0.9252115208, 0.7780731969, 

  0.5493554364, 0.2489467867, -0.09824859375, -0.4514657522, -0.7568024953]
myprint2( Vector( f~(S) ) );
8.4147d-01
9.3562d-01
9.9146d-01
9.9290d-01
9.2521d-01
7.7807d-01
5.4936d-01
2.4895d-01
-9.8249d-02
-4.5147d-01
-7.5680d-01

I hope this gives you some ideas about how to work with your function. (The same ideas work with the myprint proc.)

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

 

While you don't give us any hint as to the nature of your function (of R), this example should illustrate how you can achieve your goal.

I start with Alec's myprint2 command:

myprint2:=x->printf("%s",StringTools:-SubstituteAll(
    sprintf("%{c\n}.4e",x),"e","d")):

Your inputs with non-integer increments can be constructed using the seq command:

S := [seq( R, R=1..2, 0.1 )];
            [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0]

The myprint2 command works best on a vector (not a list):

myprint2( Vector(S) );
1.0000d+00
1.1000d+00
1.2000d+00
1.3000d+00
1.4000d+00
1.5000d+00
1.6000d+00
1.7000d+00
1.8000d+00
1.9000d+00
2.0000d+00

To get the list of function values, use map or the newer elementwise operator (~):
 

f := R -> sin(R^2):

f~(S);
[sin(1), 0.9356160016, 0.9914583482, 0.9929036511, 0.9252115208, 0.7780731969, 

  0.5493554364, 0.2489467867, -0.09824859375, -0.4514657522, -0.7568024953]
myprint2( Vector( f~(S) ) );
8.4147d-01
9.3562d-01
9.9146d-01
9.9290d-01
9.2521d-01
7.7807d-01
5.4936d-01
2.4895d-01
-9.8249d-02
-4.5147d-01
-7.5680d-01

I hope this gives you some ideas about how to work with your function. (The same ideas work with the myprint proc.)

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

 

Ben,

I do not understand your description of the problem. Here are the examples I tried:

with(plots):
plot1 := plot(sin):
plot2 := plot(cos):
display(plot1, plot2, axis[1]=[tickmarks=[-10,-5,0,5,10], gridlines=[5, subticks=true]], axis[2]=[tickmarks=8, gridlines=[8, subticks=true]]);
display(plot1, plot2, axis=[gridlines]);

In the first plot, there are thick gridlines at the 5 specified locations on the x-axis, with one thin gridline between each pair of thick lines. On the y-axis, there are 9 thick gridlines, with 4 thin subtick gridlines between each pair of thick lines. If you want to have the same number of subtick gridlines on both axes, change the subticks=true to subticks=4 (or whatever you want).

I assume you have seen the help information for plot,axis and plot,tickmarks.

Maybe you are seeing something altogether different for the specific plots that interest you. If so, please let us know how you construct your plot1, plot2, ....

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Ben,

I do not understand your description of the problem. Here are the examples I tried:

with(plots):
plot1 := plot(sin):
plot2 := plot(cos):
display(plot1, plot2, axis[1]=[tickmarks=[-10,-5,0,5,10], gridlines=[5, subticks=true]], axis[2]=[tickmarks=8, gridlines=[8, subticks=true]]);
display(plot1, plot2, axis=[gridlines]);

In the first plot, there are thick gridlines at the 5 specified locations on the x-axis, with one thin gridline between each pair of thick lines. On the y-axis, there are 9 thick gridlines, with 4 thin subtick gridlines between each pair of thick lines. If you want to have the same number of subtick gridlines on both axes, change the subticks=true to subticks=4 (or whatever you want).

I assume you have seen the help information for plot,axis and plot,tickmarks.

Maybe you are seeing something altogether different for the specific plots that interest you. If so, please let us know how you construct your plot1, plot2, ....

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

You have to pay attention to the units. You appear to be thinking that 90 is 90 degrees. Maple assumes the angles it sees are given in terms of radians. This means

cos( 90 );
                                   cos(90)
cos( Pi/2 );
                                      0

A simple way to make Maple assume the angles are given in terms of degrees is

MyCos := x -> cos( x*Pi/180 ):
MyCos(90);
                                      0
MyCos(45);
                                  1  (1/2)
                                  - 2     
                                  2       

This works fine when Maple can simplify the expression to get rid of the trig function, but I doubt you really want to see

MyCos( 50 );

                                    /5    \

                                 cos|-- Pi|

                                    \18   /

We can catch these occurrences and convert their arguments back to degrees:

MyCos := proc(x)
  local ans, toDegrees, toRadians;
  toDegrees := x -> x*180/Pi;
  toRadians := x -> x*Pi/180;
  ans := cos( toRadians(x) );
  if has(ans,{'cos','sin','tan'}) then
    ans := subsop( 1=toDegrees(op(1,ans)), ans )
  end if;
  return ans;
end proc:
MyCos(90);
                                      0
MyCos(45);
                                  1  (1/2)
                                  - 2     
                                  2       
MyCos( 50 );
                                   cos(50)
MyCos( x+y );
                                 cos(x + y)

This works only with cosine. You can do something similar with sine (and the other trig functions). But, then you are likely to want to apply double angle formulas, etc., which will require additional customizations.

It really is easiest to just learn to use radians. Students can learn these parallel names very early. They are going to have to be conversant with radians by the time they get to calculus.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

 

The answer to all of your questions is evalc.

Before asking Maple to check if two complex quantities are equal, use evalc.

q1 := 1/z = 1/(x+I*y):
q2 := 1/(x+I*y) = (x-I*y)*(1/((x+I*y)*(x-I*y))):
q3 := (x-I*y)*(1/((x+I*y)*(x-I*y))) = (x-I*y)/(x^2+y^2)
[q1,q2,q3];
             [1      1        1         1        1      x - I y]
             [- = -------, ------- = -------, ------- = -------]
             [z   x + I y  x + I y   x + I y  x + I y    2    2]
             [                                          x  + y ]

evalc([q1,q2,q3]);
       [1      x        I y       x        I y        x        I y    
       [- = ------- - -------, ------- - ------- = ------- - -------, 
       [z    2    2    2    2   2    2    2    2    2    2    2    2  
       [    x  + y    x  + y   x  + y    x  + y    x  + y    x  + y   

            x        I y        x        I y  ]
         ------- - ------- = ------- - -------]
          2    2    2    2    2    2    2    2]
         x  + y    x  + y    x  + y    x  + y ]
evalb~([q1,q2,q3]);
                            [false, true, false]
(evalb@evalc)~([q1,q2,q3]);
                             [false, true, true]
(evalb@evalc)~([eval(q1,z=x+I*y),q2,q3]);
                             [true, true, true]

Note that it's necessary to apply the evalc to each andend(?) before letting Maple make any logical comparisons:

evalc( eval( q1 and q2 and q3, z=x+I*y ) );
                                    false
evalc( eval(q1, z=x+I*y) ) and evalc( q2 ) and evalc( q3 );
                                     true

In general, evalc treats unknown quantities (here, x and y) as real variables and returns (whenever possible) an expression in the form u+I*v. So,

evalc( 1/(x+I*y) );
                                 x        I y  
                              ------- - -------
                               2    2    2    2
                              x  + y    x  + y 

I hope this helps you to understand what Maple can do and how you can get it to do what you want.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

The answer to all of your questions is evalc.

Before asking Maple to check if two complex quantities are equal, use evalc.

q1 := 1/z = 1/(x+I*y):
q2 := 1/(x+I*y) = (x-I*y)*(1/((x+I*y)*(x-I*y))):
q3 := (x-I*y)*(1/((x+I*y)*(x-I*y))) = (x-I*y)/(x^2+y^2)
[q1,q2,q3];
             [1      1        1         1        1      x - I y]
             [- = -------, ------- = -------, ------- = -------]
             [z   x + I y  x + I y   x + I y  x + I y    2    2]
             [                                          x  + y ]

evalc([q1,q2,q3]);
       [1      x        I y       x        I y        x        I y    
       [- = ------- - -------, ------- - ------- = ------- - -------, 
       [z    2    2    2    2   2    2    2    2    2    2    2    2  
       [    x  + y    x  + y   x  + y    x  + y    x  + y    x  + y   

            x        I y        x        I y  ]
         ------- - ------- = ------- - -------]
          2    2    2    2    2    2    2    2]
         x  + y    x  + y    x  + y    x  + y ]
evalb~([q1,q2,q3]);
                            [false, true, false]
(evalb@evalc)~([q1,q2,q3]);
                             [false, true, true]
(evalb@evalc)~([eval(q1,z=x+I*y),q2,q3]);
                             [true, true, true]

Note that it's necessary to apply the evalc to each andend(?) before letting Maple make any logical comparisons:

evalc( eval( q1 and q2 and q3, z=x+I*y ) );
                                    false
evalc( eval(q1, z=x+I*y) ) and evalc( q2 ) and evalc( q3 );
                                     true

In general, evalc treats unknown quantities (here, x and y) as real variables and returns (whenever possible) an expression in the form u+I*v. So,

evalc( 1/(x+I*y) );
                                 x        I y  
                              ------- - -------
                               2    2    2    2
                              x  + y    x  + y 

I hope this helps you to understand what Maple can do and how you can get it to do what you want.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Many for loops can be rewritten in terms of the seq command. (This is what your second post shows, without the explicit use of seq.)

restart;
for kn to 5 do f(k) end do;
                                    f(k)
                                    f(k)
                                    f(k)
                                    f(k)
                                    f(k)
seq( f(n), n=1..5 );
                        f(1), f(2), f(3), f(4), f(5)

Note that a significant difference in these two implementations is the treatment of the index. In the explicit do ... end do, the index has a residual value but in the seq, the index does not have a value outside the seq command:

k, n;
                                    6, n

You also ask about using the equation labels that appear beside Maple's output. This has to be done via Insert Label popup window. To activate this window, look under the Insert menu and select Insert Label .... The keyboard shortcut is CTRL-l (that's a lower case L (ell), contrary to what is displayed as the shortcut in the Insert menu). The equation label will appear in the input as, e.g., (5) - but it has to be entered through the popup window. A nice feature of using equation labels is that selecting Label Reference from the context menu (right click on the label) toggles between showing the label number and the contents associated with that label. Try it, you'll like it!

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Many for loops can be rewritten in terms of the seq command. (This is what your second post shows, without the explicit use of seq.)

restart;
for kn to 5 do f(k) end do;
                                    f(k)
                                    f(k)
                                    f(k)
                                    f(k)
                                    f(k)
seq( f(n), n=1..5 );
                        f(1), f(2), f(3), f(4), f(5)

Note that a significant difference in these two implementations is the treatment of the index. In the explicit do ... end do, the index has a residual value but in the seq, the index does not have a value outside the seq command:

k, n;
                                    6, n

You also ask about using the equation labels that appear beside Maple's output. This has to be done via Insert Label popup window. To activate this window, look under the Insert menu and select Insert Label .... The keyboard shortcut is CTRL-l (that's a lower case L (ell), contrary to what is displayed as the shortcut in the Insert menu). The equation label will appear in the input as, e.g., (5) - but it has to be entered through the popup window. A nice feature of using equation labels is that selecting Label Reference from the context menu (right click on the label) toggles between showing the label number and the contents associated with that label. Try it, you'll like it!

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

The animate command is really quite useful in situations like this. The syntax is a little strange, at first, but once you use it a couple times it really starts to make sense. There is one extra wrinkle that arises when trying to use animate to plot from a list, but we'll explain this a little later.

Here is how I would approach your problem. First, I have to make up some lists, you'll have your real data to use in this place.

drivingForceList := [1,2,3,4]:
myFunctionList := [ x/6, sin(x), cos(x), exp(-x) ]:

Next, define a procedure to create one frame of your animation:

myPlot := p -> plot( myFunctionList[ trunc(p) ], x = 0 .. 2*Pi );

Note that this procedure has to be written from the point of view that it will be given a floating-point number, which has to be converted to an integer before it's used as an index into a list. (This is the annoying part of this implementation.)

Now, the animate command is:

plots:-animate( myPlot, [ p ], p = 1 .. nops(drivingForceList), frames=nops(drivingForceList) );

It would be nice if animate worked more naturally with a discrete list of plots, but this is not so bad.

We're not done. There is one more option, trace=<number>, that tells Maple to leave <number> images as a sort of cumulative background. You might be able to use this to achieve the spacing effect you mentioned, maybe something like:

nDF := nops(drivingForceList):
plots:-animate( myPlot, [ p ], p = 1 .. nDF, frames=nDF, trace=trunc(nDF/5) );

The examples in the Maple help page for animate show how other effects can be achieved.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
First 19 20 21 22 23 24 25 Last Page 21 of 76