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

It's even simpler than this. Just click on the Help menu (at the top of the Maple window) and select What's New. 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 your last post, it is not correct to use := inside the seq. This should be:
seq( assign( u[i,0] = sin(Pi*i*h) ), i=0..nxpoints );
If you declare U to be an Array with appropriate dimensions at the top, then you could also do something like the following to impose the initial condition at time t=0 and the boundary conditions on both ends:
U := Array(0..nxpoints,0..ntsteps):
U[1..nxpoints,0]       := Array( 1..nxpoints, i->sin(Pi*i*h) );
U[0,       1..ntsteps] := Array( 1..ntsteps, 0 );
U[nxpoints,1..ntsteps] := Array( 1..ntsteps, 0 );
Inside your time loop you use
solution:=[op(solution),[(j+1)*k,seq(u[i,j+1],i=0..nxpoints)]]:
This is pretty inefficient. Since you know in advance the number of time steps, it's better to declare solution with its final size and to assign values one row during each time step:
Solution := Array( 0..ntsteps, 0..nxpoints ):
Solution[0,0..nxpoints] := Array( 0..nxpoints, i->u[i,0] );
for j from 0 to ntsteps-1 do
 ...
 Solution[ j+1, 0..nxpoints ] := Array( 0..nxpoints, i->u[i,j+1] );
 ...
end do
I don't have time to do more now. I hope this is correct enough to get you started (not all of the above code was tested). 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 your last post, it is not correct to use := inside the seq. This should be:
seq( assign( u[i,0] = sin(Pi*i*h) ), i=0..nxpoints );
If you declare U to be an Array with appropriate dimensions at the top, then you could also do something like the following to impose the initial condition at time t=0 and the boundary conditions on both ends:
U := Array(0..nxpoints,0..ntsteps):
U[1..nxpoints,0]       := Array( 1..nxpoints, i->sin(Pi*i*h) );
U[0,       1..ntsteps] := Array( 1..ntsteps, 0 );
U[nxpoints,1..ntsteps] := Array( 1..ntsteps, 0 );
Inside your time loop you use
solution:=[op(solution),[(j+1)*k,seq(u[i,j+1],i=0..nxpoints)]]:
This is pretty inefficient. Since you know in advance the number of time steps, it's better to declare solution with its final size and to assign values one row during each time step:
Solution := Array( 0..ntsteps, 0..nxpoints ):
Solution[0,0..nxpoints] := Array( 0..nxpoints, i->u[i,0] );
for j from 0 to ntsteps-1 do
 ...
 Solution[ j+1, 0..nxpoints ] := Array( 0..nxpoints, i->u[i,j+1] );
 ...
end do
I don't have time to do more now. I hope this is correct enough to get you started (not all of the above code was tested). 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/
John, Here's are several nuggets of knowledge that I find useful:
  • Never think you know what is in the online help.
  • Read, and re-read, the online help information.
  • Look at all of the examples; the last ones are often the most interesting.
Even if you've read the page before, you might be looking for something different (or maybe something has changed from a previous release). If my suggestion about max and min accepting lists or sets ever makes it into the product, there will be many users who never know because they won't re-read the help and will continue to use their old methods. I'm sure I am guilty of this myself. Often I will defend my usage on the basis of esthetics or pedagogy, but the truth is that an equal number of times it's out of ignorance or laziness that I stick to my old ways. 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/
John, Here's are several nuggets of knowledge that I find useful:
  • Never think you know what is in the online help.
  • Read, and re-read, the online help information.
  • Look at all of the examples; the last ones are often the most interesting.
Even if you've read the page before, you might be looking for something different (or maybe something has changed from a previous release). If my suggestion about max and min accepting lists or sets ever makes it into the product, there will be many users who never know because they won't re-read the help and will continue to use their old methods. I'm sure I am guilty of this myself. Often I will defend my usage on the basis of esthetics or pedagogy, but the truth is that an equal number of times it's out of ignorance or laziness that I stick to my old ways. 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'll second this proposal. Of course, this will make it more difficult to increase your score by posting corrections and additions to your own posts. (:-)) 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 cannot pinpoint the origin of this particular nugget of Maple. I know it was from an interactive source, not from reading a manual. Most likely it was on an old USENET group or the old Maple Users Group. This is the source of almost all of my Maple knowledge. One of the things that has kept me active in the Maple community is the openness and willingness of the user community to share ideas, offer suggestions, and listen to new ideas. MaplePrimes is now the main venue that I monitor. I just don't have time to monitor anything else on a regular basis. As for the suggestion about collecting tricks of the trade, Robert Israel's Maple Advisor Database (http://www.math.ubc.ca/~israel/advisor/) is the best I can recommend. This started almost 10 years ago, with Maple V (Release 4). I see that the latest version was for Maple 10. Robert, what is the status of this for Maple 11? The biggest challenge is to organize information in a way that others can find the information they are seeking. This is the real challenge. Take the current discussion about square brackets. Before I posted my response, you had no idea to even look for somethng like this. How could you have come across this in any determinstic manner? In instances like this, the learning came about because a third party took the initiative to feed you some new information. I don't see this type of activity being automated anytime soon. So, exactly what do you envision as a collection of "tricks of the trade"? Posting to MaplePrimes and knowing that one or more users are likely to respond is a pretty good first step. It's certainly better than doing a general web search, or simply burying yourself in a manual. Maybe you have something in mind? 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 cannot pinpoint the origin of this particular nugget of Maple. I know it was from an interactive source, not from reading a manual. Most likely it was on an old USENET group or the old Maple Users Group. This is the source of almost all of my Maple knowledge. One of the things that has kept me active in the Maple community is the openness and willingness of the user community to share ideas, offer suggestions, and listen to new ideas. MaplePrimes is now the main venue that I monitor. I just don't have time to monitor anything else on a regular basis. As for the suggestion about collecting tricks of the trade, Robert Israel's Maple Advisor Database (http://www.math.ubc.ca/~israel/advisor/) is the best I can recommend. This started almost 10 years ago, with Maple V (Release 4). I see that the latest version was for Maple 10. Robert, what is the status of this for Maple 11? The biggest challenge is to organize information in a way that others can find the information they are seeking. This is the real challenge. Take the current discussion about square brackets. Before I posted my response, you had no idea to even look for somethng like this. How could you have come across this in any determinstic manner? In instances like this, the learning came about because a third party took the initiative to feed you some new information. I don't see this type of activity being automated anytime soon. So, exactly what do you envision as a collection of "tricks of the trade"? Posting to MaplePrimes and knowing that one or more users are likely to respond is a pretty good first step. It's certainly better than doing a general web search, or simply burying yourself in a manual. Maybe you have something in mind? 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 remember having the same reaction when I first learned about this syntax. There is a lot more that can be done with square brackets. I am not an expert on this. This has been discussed recently on MaplePrimes. I will leave you with two more uses of square brackets that I found interesting (and useful).
f := exp(I*x);
                                  exp(I x)
evalc( [Re,Im](f) );
                              [cos(x), sin(x)]
g := x->x*exp(2*x);
                            g := x -> x exp(2 x)
[ D@@0, D, D@@2 ](g)(x);
      [x exp(2 x), exp(2 x) + 2 x exp(2 x), 4 exp(2 x) + 4 x exp(2 x)]

This is only the tip of the iceberg. Note how D@@0 is used as the identity operator. (Joe Riel recently noted the absence of an identity operator and proposed a explicit notation for such. D@@0 is not a suitable hack in many instances where the identity is needed.) Are we having fun yet? (I am!) 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 remember having the same reaction when I first learned about this syntax. There is a lot more that can be done with square brackets. I am not an expert on this. This has been discussed recently on MaplePrimes. I will leave you with two more uses of square brackets that I found interesting (and useful).
f := exp(I*x);
                                  exp(I x)
evalc( [Re,Im](f) );
                              [cos(x), sin(x)]
g := x->x*exp(2*x);
                            g := x -> x exp(2 x)
[ D@@0, D, D@@2 ](g)(x);
      [x exp(2 x), exp(2 x) + 2 x exp(2 x), 4 exp(2 x) + 4 x exp(2 x)]

This is only the tip of the iceberg. Note how D@@0 is used as the identity operator. (Joe Riel recently noted the absence of an identity operator and proposed a explicit notation for such. D@@0 is not a suitable hack in many instances where the identity is needed.) Are we having fun yet? (I am!) 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/
Personally, I like the ability to create matrices using smaller matrices. I also appreciate the need to have a matrix whose individual elements might also be matrices. My hope (wish) would be for Maple to support both. I would not object to using an additional argument to explicitly decide which format is being used. Maybe
M := Matrix( [[m1,m2],[m3,m4]], block=true );
to create an 8x8 matrix from the 4 4x4 matrices m1, m2, m3, m4. And
M := Matrix( [[m1,m2],[m3,m4]], block=false );
to create a 2x2 matrix in which each entry is a 4x4 matrix. As I understand the current situation, block=true, as the current implementation, would be the default setting. 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 use the standard interface, with worksheets and 1D Maple input. (Yes, I'm one of them.) I copied the commands from the previous post into a worksheet and executed them. I get a nicely displayed matrix. Now, if I copy the entire execution group (input and output) into this message, here is what I get:
m1:=Matrix([[1.1,2.1,3.1],[4.1,5.1,6.1]]):
m2:=Matrix([[1.2,2.2,3.2],[4.2,5.2,6.2]]):
m3:=Matrix([[1.3,2.3,3.3],[4.3,5.3,6.3]]):
m4:=Matrix([[1.4,2.4,3.4],[4.4,5.4,6.4]]):
Matrix([[m1,m2],[m3,m4]]);

                           Matrix(%id = 163173160)
Notice that the input prompts have been stripped away. Now, if I select only the output (the matrix), I get:
Matrix(4, 6, {(1, 1) = 1.1, (1, 2) = 2.1, (1, 3) = 3.1,
 (1, 4) = 1.2, (1, 5) = 2.2, (1, 6) = 3.2, (2, 1) = 4.1,
 (2, 2) = 5.1, (2, 3) = 6.1, (2, 4) = 4.2, (2, 5) = 5.2,
 (2, 6) = 6.2, (3, 1) = 1.3, (3, 2) = 2.3, (3, 3) = 3.3,
 (3, 4) = 1.4, (3, 5) = 2.4, (3, 6) = 3.4, (4, 1) = 4.3,
 (4, 2) = 5.3, (4, 3) = 6.3, (4, 4) = 4.4, (4, 5) = 5.4,
 (4, 6) = 6.4})
And, if I select only the entries in the matrix (but not the surrounding square brackets), I get:
[[1.1,2.1,3.1,1.2,2.2,3.2],[4.1,5.1,6.1,4.2,5.2,6.2],
[1.3,2.3,3.3,1.4,2.4,3.4],[4.3,5.3,6.3,4.4,5.4,6.4]]
Each of these results has a fairly believable explanation. To me, the most disconcerting is the appearance of the placeholder when the entire execution group is selected. I would certainly like some way to tell Maple that I really do want the actual matrix object to copy into another application (not just MaplePrimes). 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 idea is to derive a differential equation satisfied by the quantity of interest. This is likely to greatly increase the complexity of the system of ODEs, but it's likely Maple's dsolve,numeric could handle it. In fact, done right, it's possible this approach could do a better job of handling singularities. 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 idea is to derive a differential equation satisfied by the quantity of interest. This is likely to greatly increase the complexity of the system of ODEs, but it's likely Maple's dsolve,numeric could handle it. In fact, done right, it's possible this approach could do a better job of handling singularities. 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/
Sara, This is not a polished solution to your question about reversing the axes, but it shows one way in which this can be obtained. Start with a 2D plot.
> restart;
> with( plots ):
> p0 := plot( x^2, x=0..1 ):
The plottools package provides a transform command that creates a transformation that can be applied to a plot data structure.
> REV := plottools:-transform( (x,y)->[1-x,1-y] ):
> display( REV(p0) );
Now, to reverse the labels on the axes, use the enhanced tickmarks optional argument to plot:
> display( REV(p0), tickmarks=[[1=0,0.5=1/2,0=1],[1=0,0.5=1/2,0=1]] );
I'll guess that your next request will be to have the axes appear only on the top and right sides of the graphing window. To do this you could either manually create the axes (ugh!) or modify REV so that it plots in the third quadrant:
> REV2 := plottools:-transform( (x,y)->[-x,-y] ):
> display( REV2(p0), tickmarks=[[0=0,-0.5=1/2,-1=1],[0=0,-0.5=1/2,-1=1]] );
Look at the online help on the following topics for additional options and the details: plottools plottools/transform plot/tickmarks plot/axis plot/option While my demonstration has been for one, simple, example, the ideas can be generalized as much as you wish. Maybe someone else will supply a more general routine based on these (or better) ideas. 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 62 63 64 65 66 67 68 Last Page 64 of 76