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 answers submitted by Doug Meade

In response to your first question, you can put several Evaluate commands in a single Action. Also, one of the Evaluate's can be a call to a user-defined procedure that does more than is possible (or reasonable) in a single Evaluate. For example:
Action[Aslider](
  Evaluate( 'function'='UpdateSLD1', 'target'='TF1', Argument('SLDR') ),
  Evaluate( 'function'='UpdateSLD2' )
)
where UpdateSLD1 and UpdateSLD2 are functions you write. The first takes an argument (the value of the element called SLDR) and updates a text field called TF1. I hope this is enough to get you started. If not, reply with your specific needs. 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/~meade/
Yes! Take a look at the online help for the ErrorPlot command in the Statistics package
?Statistics,ErrorPlot
There you will see that both vertical and horizontal error bars are possible. An example, somewhat silly, is provided. Also, this command can be run in an interactive mode. Good luck! 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/~meade/
It would help if you provided an explicit example to work with. Since you didn't, I'll have to make up one and hope that my comments apply to your situation as well. If they don't, provide some more details and someone will probably be able to help.
restart;
with( plots ): # in case we will need anything from this package
A := exp(d+I*d^2);
First, I'm not going to work with the Interactive Plot Builder. I'm not saying you can't do this with the interactive tool, I'm just going to show you how to write the explicit command. I assume your "independent variable" d is a real variable. Here is a single command that could give you the plots of d vs Re(A) and d vs Im(A) in a single graph:
plot( [Re(A),Im(A)], d=-1..1 );
As a step towards the graph you requested, you could obtain the same graph as two separate parametrically-defined curves:
pR := plot( [d,Re(A), d=-1..1], color=red ):
pI := plot( [d,Im(A), d=-1..1], color=green ):
display( [pR,pI] );   # displays the two curves in one graph
The online help for parametric plots can be displayed with:
?plot,parametric
You talk about a 3-D graph, with Re(A) and Im(A) on the x- and y-axes. You never tell us what you want on the z-axis. Maybe you are really interested in a 2-D plot of Re(A) vs Im(A). If so, here is one way of getting this plot:
plot( [Re(A),Im(A), d=-1..1] );
If you want to see the curve with d in the z-axis, I recommend using the spacecurve command:
spacecurve( [Re(A),Im(A),d], d=-1..1, axes=boxed );
There are many options you can tweak through the context menus (right click on the plot) or the menu bars at the top of the Maple window. If d is a complex-valued variable, d=b+I*c, then you can probably use the complexplot3d command (see ?complexplot3d). For example:
complexplot3d( A, d=-1-I..1+I, axes=boxed );
Note that the heights reflect the magnitude of A and the colors reflect the argument of A. You might compare this with the plot obtained with
Ac := eval(A,d=a+I*b);
complexplot3d( [Re(Ac),Im(Ac)], a=-1..1, b=-1..1, axes=boxed );
Please let us know if any of this has been useful, 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/~meade/
Robert is correct on all accounts. Let me see if I can supply full explanations and corrections. The product ball PB(S1,S2) is a solid. I am most interested in its boundary. I'll talk more about this below. The worksheet has been updated to reflect the information in this message. The complete code for extracting the points for S1 and S2 is:
# Extract the points on the first surface
M1 := op( [1,1], PP1 ):
GRID1 := [ seq( seq( seq( M1[i,j,k,1..4], k=1..N ), j=1..N ), i=1..N ) ]:
PTS1 := select( v->evalb( abs(v[4])<1/N ), GRID1 ):

# Extract the points on the second surface
M2 := op( [1,1], PP2 ):
GRID2 := [ seq( seq( seq( M2[i,j,k,1..4], k=1..N ), j=1..N ), i=1..N ) ]:
PTS2 := select( v->evalb( abs(v[4])<1/N ), GRID2 ):
The correct code for constructing the points in PB(S1,S2) uses a nested seq commands:
PTS12 := [seq( seq( [v[1]*w[1],v[2]*w[2],v[3]*w[3]], v=PTS1 ), w=PTS2 )]:
Note that since PTS1 and PTS2 each contains 330 points, PTS12 contains 330^2=108900 points. These can be plotted, but the result is not really instructive. I have done some work to try to extract only the points on the boundary of PB(S1,S2) with the Categorize command from the ListTools package. This is very time consuming (as it should be). The idea I am using here is to group the points in PB(S1,S2) that have the same 2nd and 3rd components and to extract from each group the point with the largest 1st coordinate. This reduces the number of points to under 10,000.
q3 := Categorize( (a,b)->a[2..3]=b[2..3], PTS12 ):
PTS12b := [seq( [max( seq( LL[1], LL=L ) ),L[1][2..3][]], L=q3 )]:
map( nops, [PTS1,PTS2,PTS12,PTS12b] );
PP12b := pointplot3d( q4, axes=boxed, connect=false, color=blue ):
display( [PP1,PP2,PP12b] );
It would be nice to be able to view this set as a surfaces (including contour lines). With apologies for my oversights and misstatements. 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/~meade/
This works for the example you give.
solve( z^3=1, z );
                  1   1    (1/2)    1   1    (1/2)
             1, - - + - I 3     , - - - - I 3     
                  2   2             2   2         
In some cases, solve might return a response in terms of the RootOf command. In these cases you can get the information you seem to be requesting with the allvalues command.
r1 := RootOf(_Z^4+_Z^2+1);
                           /  4     2    \
                     RootOf\_Z  + _Z  + 1/

allvalues(r1);
1   1    (1/2)    1   1    (1/2)    1   1    (1/2)  1   1    (1/2)
- + - I 3     , - - + - I 3     , - - - - I 3     , - - - I 3     
2   2             2   2             2   2           2   2         
The online help for solve, RootOf, and allvalues should give you some more information about how these commands can be used. I hope this is helpful, 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/~meade/
Franky, Have you tried to use the select command? Here is how this could be used for your example:
f := ((2*m+1)*(3*m+2)*z^2)/((2*m-1)*(1+z^2)*4);
                                          2
                     (2 m + 1) (3 m + 2) z 
             f :=    ----------------------
                                  /     2\ 
                      4 (2 m - 1) \1 + z / 

f_m := select(has,f,m);
                      (2 m + 1) (3 m + 2)
             f_m :=   -------------------
                            2 m - 1      

f_z := select(has,f,z);
                                2  
                               z   
                    f_z :=   ------
                                  2
                             1 + z 
In some circumstances you might also find the collect command helpful, as a preprocessor before using select. 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/~meade/
Paolo, There are lots of ways to simplify expressions. Before giving any specific suggestions, can you provide a better idea of the expression you are working with? Please post a worksheet, or a simpler version of the full problem. Thanks, 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/~meade/
There is much more to integration than the Fundamental Theorem of Calculus (FTC). While the FTC is the main (only?) method most students see for evaluating definite integrals, there are other methods that are more appropriate, particularly for use in a CAS. The FTC depends upon being able to find an antiderivative for the integrand. The methods taught in calculus are appropriate only for a relatively small class of functions (the elementary functions: see http://en.wikipedia.org/wiki/Elementary_functions). Other methods for evaluating integrals, particularly improper integrals, are based on complex analysis. The fact that your example returns an expression in terms of Bessel and hypergeometric functions is highly suggestive that other special techniques are being used. If you really want to know how Maple arrives at this (or any) result, issue the following command:
infolevel[all] := 3;
For this example, the output is quite lengthy. You will see references to Risch, and to work being done with a variety of algebraic extensions. You will see very little that looks like anything taught in a calculus course. (Remember that Maple remembers prior results. If you do the computation, then execute the infolevel command, then re-execute the command, you will see no information - just the answer. Maple gets this from its "remember table". The best option is to restart the Maple kernel (with the restart command) before you change the infolevel.) I hope this is useful, 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/~meade/
The code posted by Scott is not correct, as it appears. I suspect the problem is that the code includes some less than symbols (<). To have a < appear in a post, it is necessary to use either the <pre> tag or to change all <'s to &lt's. Scott should be able to revise his original post, and then I should be able to delete this message as well. 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/~meade/
In the example you give:
q1 := y = x + 1;
isolate( q1, x );
I assume you have something in mind where solve cannot be used. Or, maybe you don't like the fact that solve returns only the right-hand side. But, you can get more from solve if you use the following syntax:
solve( q1, {x} );    # returns a set of solutions as equations
solve( q1, {x} )[];  # returns the contents of the set
I should also point out that isolate allows you to "solve" for more complicated objects than a simple name. For example:
q2 := sin(x)+cos(x)=1;
solve( q2, cos(x) );    # error
isolate( q2, cos(x) );  # what you expect
solve( q2, x );         # principle solutions
_EnvAllSolutions := true;
solve( q2, x );         # all solutions
I hope this gives you something useful to use, 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/~meade/
Here's a simpler way to produce the desired plots.
restart;
x1 := [7, 11, 13, 17, 19];
x2 := [12, 14, 16, 18, 20];
y1 := [1, 2, 3, 4, 5];
L1 := zip( (X,Y)->[X,Y], x1, y1 );
L2 := zip( (X,Y)->[X,Y], x2, y1 );
plot( [L1,L2], color=[red,blue], style=point, axes=boxed );
The zip command applies a function elementwise to the elements of two lists (or vectors). It's simpler than the previous seq in that it is completely independent of indices. Also, whether the lists are assembled explicitly (as above) or are included directly into the plot command, it is not necessary to use pointplot or display (or to load the plots package). If you want to have the points connected, change style=point to style=line (or omit the style option altogether). I hope this is useful, 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/~meade/
Your command is:
display( seq [ pointplot( [ r[i] ] ), i=1..2 );
There are a number of errors in this. Let's start from the inside, which is where the first error is found.
Error, (in pointplot) incorrect first argument
Each r[i] is already a list of points. There is no need to enclose r[i] inside another set of brackets. Either remove these brackets in the pointplot, or remove them from the definitions of r[1] and r[2]. To test this, try executing
pointplot( r[1] );
Good. But, when this change is made to your original command:
display( seq [ pointplot( r[i] ), i=1..2 );
Now the error message is:
Error, (in plots/tolist) points are not in the correct format
This message being generated by seq. It's not the most informative message. You get the same message if you execute
seq[ pointplot(r[i]), i=1..2 ];
The problem here is that the pointplots are being used as indices into a table named seq. You want to be calling seq, which requires the use of parentheses:
seq( pointplot(r[i]), i=1..2 );
No errors, but no plot until you display these:
display( seq( pointplot(r[i]), i=1..2 ) );
As previously comments, the two sets of data points are identical and so there is no visual difference from just plotting either r[1] or r[2]. I hope this lesson has been instructive, 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/~meade/
Thanks for the suggestions.
  • Alex' suggestion to use is has proven to be the most effective solution for my problem.
  • The suggestion to apply a logarithmic rescaling works in some cases, but also makes others more problematic.
  • I do not understand how finding asymptotes relates to determining if a function is increasing or decreasing.
The is command is very powerful, and it appears to work very nicely with the rest of the assume facility. (It should, is is part of the assume facility.) Here's a quick example of the results that I find so useful:
f := x*exp(-x);
df := diff( f, x );
is( df, negative );              # false
is( df, negative ) assuming x>1; # true
Thanks again for your feedback. 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/~meade/
Dave, Look at the results of the following commands:
P1 := plot( x^2, x=0..1 ):
P2 := plot( sin(x), x=-Pi..Pi, color=blue ):
display( [P1,P2],
         title="default viewing window" );
display( [P1,P2], view=[0..Pi/2,DEFAULT],
         title="user-specified domain" );
display( [P1,P2], view=[0..Pi/2,DEFAULT], scaling=constrained,
         title="user-specified domain w/equal aspect ratio" );
display( [P1,P2], view=[0..Pi/2,0..1], scaling=constrained,
         title="user-specified domain & range, w/equal aspect ratio" );
I hope these examples show some of the control users have over the viewing window in plots. 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/~meade/
Another option is to use the odeadvisor command provided in the DEtools package. Basically, odeadvisor will tell you the methods Maple will try to use to solve the ODE. With optional arguments, you can force odeadvisor to restrict its attention to certain types of solution methods. For full details, see the online help (?odeadvisor), and the examples therein. For more examples of the use of odeadvisor, I will shamelessly promote the Differential Equations Powertool, a collection of 35 Maple worksheets to support a full DE course. These are available on the Maple Applications Center, see http://www.maplesoft.com/applications/app_center_browse.aspx?CID=14&SCID=120. I do not know what this will do for your problem. If you can post it, we can take a look and offer more explicit suggestions. I hope this is useful, 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/~meade/
First 37 38 39 40 41 42 43 Page 39 of 44