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

Continuing Georgios' comments, here is how I would suggest combining the lists X and Y to create new columns.
R3 := map( x->1/x^2, X );
R4 := zip( (x,y)->F(x,y), X, Y );
where F(x,y) is the appropriate "complicated function of R2 and R1". There are other ways to do this, but using map and zip is much more efficient than an explicit loop. You can now plot the appropriate lists using the previously suggested methods. 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/
Maple has no trouble reading large amounts of data from a file. Converting data to the format needed for pointplot should not be that difficult. For a large collection of data, it would probably be even better to directly create the appropriate PLOT3D data structure (see ?plot3d,structure). If you can provide a sample of your data, or other details, someone on this list will almost certainly be able to provide more explicit details for how you can create the plot you seek. Looking forward to learning more about your problem, 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/
Marian, You have to read the online help for readdata carefully. When you do, you will see that readdata returns either a list or a listlist. (In your case, it is a listlist.) To work in my code, this needs to be converted to a Matrix - as you have discovered. readdata is a general purpose command. If they chose to have readdata return a Matrix (or Vector), then this would be inappropriate for anyone not wanting to use a Matrix. If you wish to work directly with the listlist, you could probably do something like
restart;
with( LinearAlgebra ):
S := 50000;               # number of data files
T := 1000;                # number of records in each data file
j := 2;
Xmat := Matrix( T, S ):   # allocate space for X matrix
for i to S do
    fname := cat(dir, "x_0.001.dat", i);
    if c mod 100 = 0 then print( c ) end if;
    Dlistlist := readdata( fname, 5 );
    Xmat[1..-1,c] := Vector(  ); # extract entry j from each sublist
end do:
You might do even better if you used readline and sscanf to store only column j of your data. Of course, if you are going to repeat this for each of the 5 columns of data, I recommend creating 5 different Matrices (Xmat1, ..., Xmat5) and doing all assignments in one loop. This reads each data file only once, which should be faster and more efficient even if it means keeping all 5 matrices in memory. I hope this is close to something that will work for you. 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/
Since I do not have access to your data files, I'll work with random matrices instead. Here is how I would approach your problem, as I understand it. A key is to define the size of your objects in advance. If you neglect this step, Maple will happily allocate new space each time a larger matrix is referenced. With matrices the size you reference, this will require lots of unnecessary memory allocations. This will be, at best, a quadratic implementation.
restart;
with( LinearAlgebra ):
S := 50000;               # number of data files
T := 1000;                # number of records in each data file
j := 2;
Xmat := Matrix( T, S ):   # allocate space for X matrix
Dmat := Matrix( T, 5 ):   # allocate space for D matrix
for c from 1 to S do
   if c mod 100 = 0 then print( c ) end if;
   Dmat := RandomMatrix( T, 5 );   # replace with readdata
   Xmat[1..-1,c] := Dmat[1..-1,j]; # column assignment
end do:
The assignment to Dmat (D is a reserved word in Maple) in the loop will be replaced by your call to readdata to read the data from the appropriate file. The last line in the loop assigns all T values in column j of the Dmat matrix to column c of Xmat. Notice that the only important colon is the one on the loop. If you change this to a semi-colon, then you will see the inner assignments - even if you use a colon on the inner assignments! The reference to the entire column is not quite as clean as in MATLAB, but it's not a problem to use. The -1 refers to the largest index value for that component. Here, you could replace the -1's with T's. Note also that you could use other negative indices to refer to other elements relative to the bottom of the matrix. E.g. -2 is the next to last row, .... Maple has two commands for system calls: system and ssystem. See the online help for the specific syntax and differences between these two commands. I hope this will be useful for your 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/
To separate two commands in a single execution group, locate the cursor between the two commands and press F3. Or, instead of pressing F3, select Edit, Split or Join, Split Execution Group. The inverse operation is the other option in the Split or Join sub-menu: Join Execution Groups. The keyboard shortcut for this is F4. By the way, an Execution Group can contain more than a single input region. Each Execution Group is marked by a square bracket at the left edge of the worksheet window. (From your original post I assume you are working with a worksheet, not a document.) 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/
Brian, Are you aware of the autoexecute feature that is supported in Maple? If not, check out the online help for the topic worksheet/documenting/executiongroups. (?worksheet/documenting/executiongroups) By default, autoexecute sections are executed when the worksheet/document is first opened. They can be re-executed at any other time via the Repeat Autoexecute entry in the Edit menu. All of this is explained in the online help. Hoping this will lead to an answer to your question, 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 should be no problems with any of the problems you describe. Please provide the exact problems you are trying to solve. You can easily upload a Maple worksheet (there is a convenient link immediately above the box where you compose your post.
  1. It's clear to me that the snippets of code in your message are re-entered, not taken directly from a Maple worksheet. The command names are fsolve and solve (not FSolve and Solve).
  2. As you entered it, your equation does not involve x or y (or a or b). While you might be intending to use implied multiplication, this is not what you show.
  3. The syntax I would suggest for doing something like what you describe would be: eq := eval( a*x+b*y=c, [a=p1,b=p2,c=p3] ); # assuming p1, p2, and p3 have been assigned numeric values fsolve( eq, {x=1..2,y=2..3} )
  4. As stated, there are an infinite number of solutions to your equation. Specifying the domain does nothing here. Also, this problem is simple enough that there is no reason to use fsolve. It can be solved exactly, with solve (just omit the ranges).
Once we have a better understanding of the problem you are trying to solve, I'm confident you will find answers to your questions in this forum. 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/
Assuming you are actually typing the Maple command (and not using a palette), you want to use Maple's inert differentiation command - Diff. For example:
a := Diff( x^2, x );
latex( a = value(a) );
This also shows the use of value to force Maple to evaluate the inert expression. In addition to Diff, Maple contains Limit and Int (inert versions of limit and int). If you are using the palette, with 1-D input, you will need to manually change diff to Diff. I doubt this distinction can be made when using 2-D input - another reason I choose to use 1-D input. I hope this has been 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/
Tim, Does this do what you want?
> P := NULL:
> for i from 4 to nops(tListList) do
>   P := P, plot(BSplineCurve( tListList[1..i], v ),v=1..10);
> end do:
> display( P, insequence=true );

This plots the spline as each new point is added. If this is not want you want, maybe the general idea will be helpful for putting together a different animation.

With hopes 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/
The syntax
limit( (sin(k*Pi) assuming k::integer), k=infinity );
could be acceptable, but it's not always this simple. In many cases it appears to be necessary to include simplify:
limit( simplify(sin(k*Pi)) assuming k::integer, k=infinity );
This is starting to push things a little further than I'd like. In fact, while the "extra" parentheses in the first argument are not a problem for me to insert, this is more than I would like to have to explain to students. Compare:
limit( (a assuming k::integer), k=infinity );
                                      0
limit( a assuming k::integer, k=infinity );
   Error, invalid input: limit uses a 2nd argument, p
   (of type Or(name = algebraic, set(name = algebraic))),
   which is missing
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/
Ah, the pleasures of evaluation. The subs command does not do any evaluation. So, in your case you should do something that forces the output from subs to be evaluated. For example:
> myDG1:= u(t) + diff(u(t),t)^2 + v(t)=0:
> myDG2 := subs(u(t)=K,myDG1);

                                      2           
                               / d   \            
                           K + |--- K|  + v(t) = 0
                               \ dt  /            
> value( myDG2 );
                                K + v(t) = 0
> simplify( myDG2 );
                                K + v(t) = 0
Another alternative is to use the eval command:
myDG3 := eval( myDG1, u(t)=K );
                                K + v(t) = 0
Note that it is not necessary to tell Maple that K is a constant. If you entered K(t) instead of K, then Maple would know K was not a constant - and actually depends on t. See also the online help for both subs and eval. I hope this has been 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/
I have fixed your problem. The problem appears to be that the value of Plotter element must be a Maple plot data structure. You created a Maple plot in your procedure, but it was not necessarily the value returned by that procedure. You will see the very minor changes I made in your worksheet, which can be accessed at View 178_ShortVersion2.mw on MapleNet or Download 178_ShortVersion2.mw
View file details Hoping 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/
Please replace this text with the link to your file. The link can be found in the File Manager
I have re-read the original post in this thread. The original commands posted were:
I have with(plots) and restart() at the top of my page. I then do this: g1 := implicitplot(3x^2,x=0..10,y=0..10); display( g1 ); This results in it just printing the display line again, no graph is shown.
From this, I believe our responses have been mostly on target. It is not clear that the with(plots) came after the restart. This is essential as the restart would undo the loading of the plots package. Next, there is the issue of the multiplication operator in 3x^2. If this came from 2D Maple Input, then it's possible the syntax is OK. But, the real issue here is that when implicitplot receives an expression as its first argument, Maple converts this to an equation with RHS 0. In this case, 3*x^2=0. Thus, this plot is just the vertical segment x=0 for 0<=y<=10. With the standard axes, this would be invisible. In such situations I change to framed axes, or ask to see the points instead of the line, or increase the thickness. All of these can be done via the command line, the context menu, or the interface. This is the reason many of the responses changed to using plot instead of implicitplot. If you really do want an implicitplot, then you should use the syntax
implicitplot( y=3*x^2, x=0..10, y=0..10 );
Lastly, if you have more problems, or oddities, it's probably better if you post the worksheet / document to let us see exactly what you have tried and how Maple has responded. Hoping hoping this is useful to someone, 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/
Laurent is correct that there are many things that are easier to do with embedded components. Maybe this will work for Court. But, my experience also suggests that there are many things in an embedded component that cannot be controlled to the degree that they can be controlled in a maplet. Even things such as colors, names, .... Also, there are many times when I do not want to overhead of a worksheet (or document) and want a stand-alone GUI. I have to admit that I have not looked at the improvements to embedded components in Maple 11. Can you give me some indications of the recent improvements? 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 sounds like you have not loaded the plots package. Are you sure you executed the with( plots ) command after the restart? To be sure this command is being executed, change the colon (:) to a semi-colon (;) and execute this command. Your output should be the list of plot commands that are defined in the plots package.
restart:
with( plots );
g1 := plot( 3*x^2, x=0..10, y=0..10 ):
g2 := plot(10*x^2, x=0..10, y=0..10 ):
display( g1, g2 );
I have introduced some extra white-space in the commands to make them a little more readable. You should also note that your viewing window is not optimal. Personally, I would not put the vertical limits in the plot commands. Rather, I would specify this only once, in the display command, as follows:
h1 := plot( 3*x^2, x=0..10 ):
h2 := plot(10*x^2, x=0..10 ):
display( h1, h2, view=[0..2,0..10] );
Of course, if you know you are only going to be looking at the domain [0,2], then you should reflect this in the plot commands. The following will produce a somewhat smoother plot (look closely, near the origin).
j1 := plot( 3*x^2, x=0..2 ):
j2 := plot(10*x^2, x=0..2 ):
display( j1, j2, view=[0..2,0..10] );
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 36 37 38 39 40 41 42 Page 38 of 44