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

If you really want to change the definition, just edit the earlier command and re-execute. There is no need to remove the assignment.

x := 3*sin(y);

Oops. This should have been cos:

x := 3*cos(y);

You do need to unassign a name if you want to completely erase all assignments that have been made to a name. For this I recommend unassign or back quotes:

unassign( 'x' ); # here the single quotes are used to delay evaluation
x:

x := A;
x := `x`;  # but here back quotes are needed to assign the symbol x to the name x (thereby replacing any current value assigned to x)

I hope this provides some additional understanding,

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 original post describes this surface as being below the x-y plane. But, with phi = 0 .. Pi/2 , the z-component will be positive so the surface is above the x-y plane. The part of this surface below the x-y plane would be obtained with phi = Pi/2 .. Pi .

The previous responseattempted to address this by taking the theta's from 0 to -4*Pi. But, look closely and you will see that this is not quite right. Also, in that approach, there is no need to define x, y, or z. All you need is:

r := theta;
plot3d([r, theta, phi], theta = 0 .. 4*Pi, phi = 0 .. Pi/2, coords = spherical);   # z<0
plot3d([r, theta, phi], theta = 0 .. 4*Pi, phi = Pi/2 .. Pi, coords = spherical);  # z>0

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

The original post describes this surface as being below the x-y plane. But, with phi = 0 .. Pi/2 , the z-component will be positive so the surface is above the x-y plane. The part of this surface below the x-y plane would be obtained with phi = Pi/2 .. Pi .

The previous responseattempted to address this by taking the theta's from 0 to -4*Pi. But, look closely and you will see that this is not quite right. Also, in that approach, there is no need to define x, y, or z. All you need is:

r := theta;
plot3d([r, theta, phi], theta = 0 .. 4*Pi, phi = 0 .. Pi/2, coords = spherical);   # z<0
plot3d([r, theta, phi], theta = 0 .. 4*Pi, phi = Pi/2 .. Pi, coords = spherical);  # z>0

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

Why go to the trouble of finding a numerical solution?

If your "nonlinear DE" can be written as F( t, x(t), diff(x(t),t) ) = 0, then the first derivative is zero whenever F( t, x(t), 0 ) = 0 . Hopefully your actual DE is not so complicated that this is impossible to do. And, if it is, you might still be able to use Maple's fsolve command to approximate the locations with horizontal tangents. Both of these approaches appear to answer the question  you have posed - without actually "solving" the DE.

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

Why go to the trouble of finding a numerical solution?

If your "nonlinear DE" can be written as F( t, x(t), diff(x(t),t) ) = 0, then the first derivative is zero whenever F( t, x(t), 0 ) = 0 . Hopefully your actual DE is not so complicated that this is impossible to do. And, if it is, you might still be able to use Maple's fsolve command to approximate the locations with horizontal tangents. Both of these approaches appear to answer the question  you have posed - without actually "solving" the DE.

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

It would also be nice to have an "until" clause in the do statement. This can usually be worked around, but there are many times when "until" is more natural than "while" and cleaner than using "break".

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

I don't have much time right now, but hope I can get you a little closer to a solution.

Notice that the P in Robert's post is a plot3d data structure but your PlotFrame is a procedure that returns a plot3d data structure.  Maybe you need to modify the first argument to be PlotFrame(1), for example. Or, maybe you need to put the evalindets inside your PlotFrame, like:

PlotFrame := i -> evalindets( plots:-display(E[i]), listlist, breaker, evalf([4,3,2]), evalf([2,3,4]) ) end proc;

For your testing purposes, get a command that produces a plot3d. Then put the same command in the first argument of evalindents and experiment with exactly how the last two arguments need to be specified.

And, I repeat that a complete example showing exactly what you have tried would be most beneficial.

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

I don't have much time right now, but hope I can get you a little closer to a solution.

Notice that the P in Robert's post is a plot3d data structure but your PlotFrame is a procedure that returns a plot3d data structure.  Maybe you need to modify the first argument to be PlotFrame(1), for example. Or, maybe you need to put the evalindets inside your PlotFrame, like:

PlotFrame := i -> evalindets( plots:-display(E[i]), listlist, breaker, evalf([4,3,2]), evalf([2,3,4]) ) end proc;

For your testing purposes, get a command that produces a plot3d. Then put the same command in the first argument of evalindents and experiment with exactly how the last two arguments need to be specified.

And, I repeat that a complete example showing exactly what you have tried would be most beneficial.

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 datapoints in PlotFrame are more than likely floating-point numbers. Your breakpoints are given with integers. Try putting evalf around each of the last two arguments to evalindets, like this:

evalindets(PlotFrame, listlist, breaker,evalf ([4,3,3]), evalf([2,3,4]));

or enter each point as a floating-point number:

evalindets(PlotFrame, listlist, breaker, [4.,3.,3.],([2.,3.,4.]);

Does that help?

Hmm. You said "nothing shows up". If the above is correct, then I would expect you to see the full plot with nothing removed.

What do you see in PlotFrame? Does this produce a valid plot? If not, then this is where you need to be looking. If it is a good plot, would it be possible for you to show us a simple case showing us how it does not work?

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 datapoints in PlotFrame are more than likely floating-point numbers. Your breakpoints are given with integers. Try putting evalf around each of the last two arguments to evalindets, like this:

evalindets(PlotFrame, listlist, breaker,evalf ([4,3,3]), evalf([2,3,4]));

or enter each point as a floating-point number:

evalindets(PlotFrame, listlist, breaker, [4.,3.,3.],([2.,3.,4.]);

Does that help?

Hmm. You said "nothing shows up". If the above is correct, then I would expect you to see the full plot with nothing removed.

What do you see in PlotFrame? Does this produce a valid plot? If not, then this is where you need to be looking. If it is a good plot, would it be possible for you to show us a simple case showing us how it does not work?

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

I no longer have Maple 6 at my disposal, so I assume this is something that must have changed over the last few years.

Since you say my other suggestions worked for you, I assume you were able to get around this problem. In case you have any lingering questions, all of the following should produce similar results:

with( LinearAlgebra ):
A:=Matrix(2,2,[4, 12, 2, 0.04]);
A:=Matrix(2,2,[[4, 12], [2, 0.04]]);
A:=Matrix(2,2,< <4|12>, <2,0.04> >);
A:=< <4|12>, <2,0.04> >;

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

I no longer have Maple 6 at my disposal, so I assume this is something that must have changed over the last few years.

Since you say my other suggestions worked for you, I assume you were able to get around this problem. In case you have any lingering questions, all of the following should produce similar results:

with( LinearAlgebra ):
A:=Matrix(2,2,[4, 12, 2, 0.04]);
A:=Matrix(2,2,[[4, 12], [2, 0.04]]);
A:=Matrix(2,2,< <4|12>, <2,0.04> >);
A:=< <4|12>, <2,0.04> >;

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

It's now been almost two months since my last response, and the Wiley webpage does exist - but it's not been updated to include the 3rd edition.

Frustrating,

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

Sure enough. It's still a problem in Maple 13.

CodeGeneration:-Matlab( x^(1/y) );
cg0 = x ^ 0.1e1 / y;
CodeGeneration:-Matlab( x^(2/y) );
cg1 = x ^ (2 / y);
CodeGeneration:-Matlab( x^(b/y) );
cg2 = x ^ (b / y);

And, to confirm that MATLAB does, in fact, parse these expressions as we expect it to:
>> x = 2;
>> y = 3;
>> cg0 = x ^ 0.1e1 / y

cg0 =

    0.6667

>> cg0 = x ^ (0.1e1 / y)

cg0 =

    1.2599

I'll submit an SCR on this, and let someone else dig through the definitions in CodeGeneration to find the actual bug.

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

Or, just use the dchange command in the PDEtools package (the replacement for the dchangevar command in DEtools):

ODE := diff(f(x,y),x$2) + diff(f(x,y),x) + diff(f(x,y),y);
             / d  / d         \\   / d         \   / d         \
             |--- |--- f(x, y)|| + |--- f(x, y)| + |--- f(x, y)|
             \ dx \ dx        //   \ dx        /   \ dy        /
dchange( {x=xi*x0, y=zeta*z0}, ODE, [xi,zeta] );
          d   / d                      \    d                      
         ---- |---- f(xi, zeta, x0, z0)|   ---- f(xi, zeta, x0, z0)
          dxi \ dxi                    /    dxi                    
         ------------------------------- + ------------------------
                         2                            x0           
                       x0                                          

                d                       
              ------ f(xi, zeta, x0, z0)
               dzeta                    
            + --------------------------
                          z0            

Note that you have to express the original variables in terms of the new variables, not the other way around.

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 25 26 27 28 29 30 31 Last Page 27 of 76