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

There are numerous ways to do this. The way that is best for you depends on your style as well as the specifics of your problem. In the linked worksheet I show a few possibilities. View 178_MultiPlotExamples.mw on MapleNET or Download 178_MultiPlotExamples.mw These fall into two separate cases: - functions on overlapping intervals - functions on disjoint (open) intervals While my example in the second case uses adjoining intervals (as in your original question), this could be extended to situations where there is a gap between the domains of the two functions as well. I hope this is useful, Doug ----------------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Robert, Try
 plot( f, x=-10..10, y=0..10, linestyle=DOT );
The online help for plot/options indicates that the other values that can be assigned to linestyle are:
linestyle=n
  Controls the dash pattern used to render lines in the plot. The
  linestyle can be specified as either an integer between 1 and 4,
  or a name from the following list: SOLID, DOT, DASH, or DASHDOT.
  The value must be in uppercase.
I hope this answers your question. Doug ------------------------------------------------------------------ Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Take a look at the various printf commands: printf, fprintf, nprintf, sprintf. Each of these commands accepts a C-like format to be used to display an object. The different commands accept the same arguments. printf sends the output to the default stream, fprintf sends the output to a file, nprintf produces a Maple name, and sprintf returns a Maple string. There are a variety of floating-point formats: e - exponential, f - fixed point, g - combination of e and f, y - HEX. See the online help for printf (?printf) for a complete explanation, including various modifiers that might be appropriate for your specific case. Examples:
x := 12345.678:
printf( "%e", x );
printf( "%6.4e", x );
I hope this helps, Doug ----------------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
A careful reading of the online help for plots[multiple] leads me to the understanding that each plot's arguments must be in a list. Since you are plotting parametric curves, which are themselves specified as a list, you need to enclose each curve in an extra set of square brackets. Also, it appears that you have omitted all multiplications (*), the sin and cos in the last curve, and the view option should be used to set the viewing window. Here is a working version of your command: plots[multiple](plot, [[0.71*cos(2.985074627*Pi*t), 0.71*sin(2.985074627*Pi*t), t = 0 .. 67]], [[cos(2*Pi*t), sin(2*Pi*t), t = 0 .. 1]], [[1.5*cos(1.063829787*Pi*t), 1.5*sin(1.063829787*Pi*t), t = 0 .. 1.88]], [[5.12*cos(0.1680672269*Pi*t), 5.12*sin(0.1680672269*Pi*t), t = 0 .. 11.9]], [[9.40*cos(0.06779661017*Pi*t), 9.40*sin(0.06779661017*Pi*t), t = 0 .. 29.5]], view=[-10..10,-10..10]); There are easier ways to produce this plot. First, you can use a single plot command: plot( [ [0.71*cos(2.985074627*Pi*t), 0.71*sin(2.985074627*Pi*t), t = 0 .. 67], [cos(2*Pi*t), sin(2*Pi*t), t = 0 .. 1], [1.5*cos(1.063829787*Pi*t), 1.5*sin(1.063829787*Pi*t), t = 0 .. 1.88], [5.12*cos(0.1680672269*Pi*t), 5.12*sin(0.1680672269*Pi*t), t = 0 .. 11.9], [9.40*cos(0.06779661017*Pi*t), 9.40*sin(0.06779661017*Pi*t), t = 0 .. 29.5] ], x=-10..10, y=-10..10 ); If you do not like having the curves appear as different colors - or you want to use different colors - include the color option. Lastly, I have to mention that it's even easier to create this plot if you simply plot 5 circles in polar coordinates: plot( [0.71, 1.0, 1.5, 5.12, 9.4], theta=0..2*Pi, coords=polar, view=[-10..10,-10..10], legend=["Mercury", "Venus", "Earth", "Mars", "..."] ); I also included a legend in this plot. To see the full set of possible options, I suggest taking a look at the online help for plot,options (?plot,options). I hope this helps. Doug ----------------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Matthew, Maple's online help system is very nice. Not only does it tell you how to use a command, in many cases it will also tell you exactly how the command works. In the case of ifactor, type ?ifactor at a command prompt (or use the help browser). One of the sections in the help window will be titled "Description". Here is the content from that section: ================================================ Description ifactor returns the complete integer factorization of n. The answer is in the form: u * ``(f1)^e1 * ... * ``(fn)^en such that n = u * f1^e1 * ... * fn^en where u equals sign(n), f1, ..., fn are the distinct prime factors of n, and e1, ..., en are their multiplicities (negative in the case of the denominator of a rational). The expand function may be applied to cause the factors to be multiplied together again. If a second parameter is specified, the named method will be used when the front-end code fails to achieve the factorization. By default, the Morrison-Brillhart algorithm is used as the base method. Currently accepted names are: 'squfof' - D. Shanks' undocumented square-free factorization; 'pollard' - J.M. Pollard's rho method; 'lenstra' - Lenstra's elliptic curve method; and 'easy' - which does no further work. If the 'easy' option is chosen, the result of the ifactor call will be a product of the factors that were easy to compute, and a name _c.m._.n indicating an m-digit composite number that was not factored where the n is an integer which preserves (but does not imply) the uniqueness of this composite. The pollard base method accepts an additional optional integer: ifactor(n, pollard, k), which increases the efficiency of the method when one of the factors is of the form k*m+1. ================================================ Now you know the different algorithms that are being used by ifactor. A general library (or web) search will turn up explicit references to the different methods used by Maple. Another great feature of Maple is that that most commands are implemented directly in the Maple programming language, and this code is visible to the user. In this case, try executing the following commands: showstat( ifactor ); showstat( `ifactor/ifact1st` ); showstat( `ifactor/wheelfact` ); The first command shows the actual Maple code that is executed whenever the ifactor command is used. Within this procedure you will see calls to several other procedures. Two of these procedures are displayed with the second and third commands above. (The online help for showstat will provide more information about this command as well. See ?showstat) The Maple debugger is useful for understanding how Maple arrives at a response. See ?debugger) While this is not an explicit answer to your question, you now have the tools to help you find as much information about Maple's factorization as you want. Doug ----------------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Here is the text from my worksheet. I apologize that it does not appear in a better format, but MaplePrimes objects to this if I use any type of markup (e.g., surrounding the code block with
).

restart;
with(Maplets[Elements]):
with(Maplets[Tools]):
Calc:= proc()
  Set(result=cos(Get(theta::anything)) );
end proc:
DKP:= Maplet(onstartup = A0,
  Window[W1](title="DKP", [ TextField[theta](),
                            TextField[result](),
                            Button("Calculate", onclick = A1)
                          ]),
  Action[A1](Evaluate( function='Calc' )),
  Action[A0](RunWindow(W1))
):
Maplets[Display](DKP);

-------------------------------------------------------------------
Prof. Douglas B. Meade     Phone:  (803) 777-6183
Department of Mathematics  URL:    http://www.math.sc.edu/~meade/
USC, Columbia, SC 29208    E-mail: mailto:meade@math.sc.edu
Communication among elements in a maplet window is done with the Get and Set commands. I have a working version of your maplet, but at present the worksheet converter produces HTML code that MaplePrimes refuses to display. (The complaint I see, in a separate window, is "Terminated request because of suspicious input data.".) I will continue to attempt to post this worksheet to MaplePrimes. If you would like to receive my worksheet by e-mail, please send a message to me at the address in my .signature. Doug --------------------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
The zip command can be used to do componentwise operations on matrices (or vectors or lists). Here is a simple example to illustrate:

> with( LinearAlgebra ):

> A := RandomMatrix( 2,2 );

Maple Equation

> B := RandomMatrix( 2,2 );

Maple Equation

> zip( (a,b)->a/b, A, B );

Maple Equation

>

This post generated using the online HTML conversion tool
Download the original worksheet

If this is going to be done repeatedly I recommend creating a Maple procedure for this operation. Here is how that could be done:

> MatDivide := (A,B) -> zip( (a,b)->a/b, A, B );

The same ideas can be used to define many other functions that are to be applied elementwise to pairs of matrices.

I hope this is helpful.

Doug

-----------------------------------------------------------------
Prof. Douglas B. Meade Phone: (803) 777-6183
Department of Mathematics URL: http://www.math.sc.edu/~meade/
USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu

I always enjoy working with the output from a numerical solution to an IVP. There are many ways to approach this problem. Two possibilities are illustrated in the attached worksheet. The basic ideas begin the same:
  1. The output from dsolve is a procedure that returns a list.
  2. Evaluate this at the desired value of the independent variable.
In the first approach (FUNC) the idea is to throw away the first element of the list (t=...) and all elements of the list that involve a derivative. Only the right-hand sides of these elements are returned.

In the second approach (FUNC2) an additional argument is used to specify the explicit list of quantities to return. Note that these quantities can be more complicated expressions formed from the elements of the solution vector (very similar to what is possible with odeplot).

Here is the full content of this worksheet:

> with(DEtools):

> n:=5: #(n can be as large as 500..

> eqn1:=diff(u||1(t),t$2)=exp(u||(2)(t)-u||1(t))-exp(u||(1)(t)-u||(n)(t)):

> sys:=[seq(diff(u||i(t),t$2)=exp(u||(i+1)(t)-u||i(t))-exp(u||(i)(t)-u||(i-1)(t)),i=2..n-1)]:

> eqnn:=diff(u||n(t),t$2)=exp(u||(1)(t)-u||n(t))-exp(u||(n)(t)-u||(n-1)(t)):

>

> sys:=[eqn1,op(sys),eqnn]:

>

> IC1:=[seq(u||i(0)=1,i=1..n)]:

> IC2:=[seq(D(u||i)(0)=0,i=1..n)]:

> IC3:=[op(IC1),op(IC2)]:

>

> soln:=dsolve({op(sys),op(IC3)},numeric,output=procedurelist):

> soln(2.);

>

> FUNC := proc(soln,t)

>   local S;

>   if not type(evalf(t),numeric) then return 'procname'(args) end if;

>   S := remove(has,soln(t)[2..-1],diff);

>   return map( rhs, S );

> end proc;

> FUNC(soln,t);

> FUNC(soln,2);

>

> FUNC2 := proc(soln,fns,t)

>   if not type(evalf(t),numeric) then return 'procname'(args) end if;

>   return eval( fns, soln(t) );

> end proc;

> fns := [seq(u||i(t), i=1..n )];

> FUNC2(soln,fns,1);

>

This post generated using the online HTML conversion tool
Download the original worksheet

There are many different ways to implement these ideas. I hope these give you some useful possibilities.
Here's my approach to this problem:

> restart;

> with( plots );

Maple Equation

> A:=matrix([[1.00, 1.00, 167.76], [1.00, 2.00, 95.588], [2.00, 1.00, 500.64], [2.00, 2.00, 335.51]]);

Maple Equation

>

> A2 := convert(A,listlist);

Maple Equation

> plots[pointplot3d]( A2, style=line, axes=boxed );

Maple Plot

>

This post generated using the online HTML conversion tool
Download the original worksheet

This does not create a surface (how would Maple know which points to connect?) but does show how to convert a matrix into a form that can be plotted.

I hope this helps.

Doug

Since you are asking about a Label, I assume that you are not looking for this field to be active, or to do anything. It's just to display some information. This information could change based on some other action, but this field does not initiate any action. If my assumption is correct, my recommendation is to replace the Label with a MathMLViewer. In this case you could create the "label" with
  BoxRow(
    "L = ",
    MathMLViewer['MMLlabel'](
      'height'=60,
      'width'=300,
      'value'=MathML[Export](Limit(a[n],n=infinity))
    ),
    HorizontalGlue()
  )
You could, of course, put the "L=" in the MathML viewer as well, but I show this as a way to combine a traditional label with the MathMLviewer. Suppose you later have a specific sequence with terms given in the Maple variable TERM. The displayed string in the "label" could be changed as follows:
  Set('MMLlabel'('value')
   = MathML[Export](Limit(TERM,n=infinity)=limit(TERM,n=infinity));
I hope this does help. ------------------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Patrick, I am not an expert with the new document mode, but this should not be too difficult to achieve. I would recommend using the Matrix palette to enter the table. In your case, you would have 3 rows and 4 columns (make no changes to the other settings). After pressing Insert Matrix you can enter each element of the table (using Tab to move to the next element). If the matrix appears in an output region it will have a Maple-generated label, say (1). In this case you can refer to specific elements of the matrix using Insert - Label... to enter the label number and then adding the reference to the specific element, e.g., (1)[2,3] - not the most elegant, but not unreasonable either. A better possibility is to make the assignment in a separate document block. This block could be marked to auto-execute and then collapsed or otherwise made invisible. Then, you should be able to reference elements of the table using your preferred name, e.g., T[2,3]. I hope this helps. Doug
I will address only the partial fraction expansion part of your question. I'll let someone with more experience with the geometry packages help you on the other part of your question. You can use the op command to extract a specific summand: > > op(5, a+b+c+d+e+f+g+h+i+j ); > The numer command returns the numerator of a rational expression. The normal command can be used to combine two or more rational expressions into a single rational expression. > numer( top/bottom ); > This post generated using the online HTML conversion tool Download the original worksheet I hope this is helps. ----------------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Carolus, I can provide two suggestions to produce Maple plots without labels: use the labels option to the plot command or plot a function (not an expression). The following examples illustrate both of these ideas. plot( sin(x), x=0..Pi ); # plot of expression with label on x-axis plot( sin(x), x=0..Pi, labels=["",""] ); # explicit label suppression plot( sin, 0..Pi ); # plot of function In that last case, note that it would be an error to use x=0..Pi as there is no reference to x in the first argument. If you need more detailed information, please see the online help (?plot,options) or follow-up with more specifics about your needs. I hope this helps, Doug ----------------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Interesting. I have not found a complete explanation for your result, but do agree that it is surprising. Here is some more information on this problem: > restart; > assume( L=1/2 ); > assume( x>0, y>0 ); # makes no difference if this is additionally > additionally(x + y < L); > is(x < L); # true (OK) > is( 2*L/(1-x-y)<1 ); # FAIL (should be false) > is( 1-x-y>0 ); # true (OK) > is( 2*L < 1-x-y ); # false (OK) > is( 2*L = 1 ); # true (OK) > is( 1 < 1-x-y ); # false (OK) > > is( 2*L>1-x-y ); # true (OK) > is( 1-x-y>0 ); # true (OK) > is( 2*L/(1-x-y)>1 ); # FAIL (should be true) > > about( x, y, L ); All quoted results are for Maple 10.01. Doug ----------------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
First 41 42 43 44 Page 43 of 44