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

The animate command is very powerful. The basic idea is to write   a procedure that creates a single frame of the animation in terms of a single parameter.

The help page for plots,animate is very informative and instructive. You should read it, where you  will find this as the last example:

F := proc(t)
plots[display](
plottools[line]([-2,0], [cos(t)-2, sin(t)], color=blue),
plottools[line]([cos(t)-2, sin(t)], [t, sin(t)], color=blue),
plot(sin(x), x=0..t, view=[-3..7, -5..5])
);
end proc:
animate(F,[theta], theta=0..2*Pi,
background=plot([cos(t)-2, sin(t), t=0..2*Pi]),
scaling=constrained, axes=none);

The procedure F takes one argument and creates one frame of the animation. (Note that each frame consists of 3 separate plots that are collected into a single plot structure with the plots:-display command.)

I should point out that the animation also has a static background. See the help page for complete details about this as well.

I would use these tools to create the animation you provided.

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

@Alejandro Jakubi You now completley understand my request, and why it is so difficult (and interesting).

I understand the limited time as well. This does seem like it might be something that comes to mind when you are least thinking about this specific question. I trust you'll be able to remember the critical insight should this occur for you.

Your definitions for m are cut off. If I could see the entire expression, maybe I could confirm that fsolve is not working - and to offer some suggetions.

As a first question I'll ask why you believe there should be a solution and what (if anything) you know about the solution(s)?

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

@Alejandro Jakubi Thank you for your example and comments. The example shows that contour integration can be more efficient. But, it does not meet my requirement. I want an example that Maple cannot evaluate by FTOC that it can evaluate using contour integration.

If I ask a little more, I want an example that Maple cannot evaluate by any of the other methods in its default list of methods 

I hope might have some ideas about this as well.

Doug

@Alejandro Jakubi A colleague has asked me if there are any examples where Maple's int is able to evaluate a definite integral with contour integration. Can you, or someone else, provide me with an explicit example of this?

My thinking is that Maple's extensive knowledge of special functions makes it somewhat difficult to come up with an example.

What do you have to offer?

@Markiyan Hirnyk Interesting. While this could be called a "workaround" for this specific case, how would you identify the cases where this is needed, and implement this in a general way? If this is really to be expected - and accepted - then I would expect Maplesoft to have done this programming for us.

With the other confirmations of the errors involved with this example, this is a bug. While I do not yet know the full range of problems for which incorrect results are produced, it is clear that this could be significant in a variety of situations.

I'll make an official report to Maplesoft.

I have to admit that I had not thought about using `if` in this way, but I'll have to add it to my list of tricks.

I also want to point out that some of these examples are very easily (and logically) implemented using the select command. For example:

nops( select( a->a<0, L ) );
27
nops( select( is, L, negative ) );
27

select( isprime, [$1..n] );
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]

I don't see immediate ways to implement the test involving consecutive elements or rows of a matrix using select. I'm sure others might see a way to do these using select.

I do wonder how these different approaches compare in terms of efficiency. As much as I'd like to do some of these tests, my day is done and I need some rest.

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

Your example is not consistent with your description: a^k = 2^6 = 64 = b but not b^2. Please clarify what you intend.

Also, you say you have done some preliminary effort to solve this. It would probably be helpful is you could share your work with us to let us know what you have tried and where you might need to make some changes.

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

@Christopher2222 

Your code provides a proof of concept. The challenge is to find a way to do this that works for "all" cases. For starters, it certainly should not provide a graph that looks worse that the one currently returned by plot3d. This is not going to be easy. I don't claim to know how to do this myself.

I would add that this first attempt appears that it requires about twice the processing time as a single call to plot3d. I say this because every call generates the plot3d object, then decides to either call implicitplot3d or plot3d (again). A simple improvement in efficiency can be achieved with the following:

newplot3dA := proc(a,b,c,d)
local p;
p := plot3d(a,b,c);
if has( op([1,3],p), HFloat(undefined) )
then plots:-implicitplot3d( a^2=z^2, b,c,d );
else p;
end if;
end proc;

This avoids the use of the StringTools package, the type conversions, and a second call to plot3d. It does not fix any of the functionality issues.

A real solution will almost certainly not require a full call to plot3d to get started. It should be possible to do some quick processing to determine if there are going to be any issues.

The real challenge that I see is exactly what transformation needs to be applied to come up with the suitable implicit form for the surface. We'll start with z=a, but will then need to look for transformations of this that do not change the surface but will be easier to plot.

I should note that the use of z^2=a^2 is not perfect either as this also includes z=-a. To see this, change the z range to include some negative values (z=-1..6 or z=-6..6). The correct output should still be only the top half of the sphere.

This is not going to be easy - but could be very beneficial. I hope our interest will motivate Maplesoft to commit some resources to it. I think this has the potential to be useful throughout their range of products, including MapleSim.

Doug

@Christopher2222 

Your code provides a proof of concept. The challenge is to find a way to do this that works for "all" cases. For starters, it certainly should not provide a graph that looks worse that the one currently returned by plot3d. This is not going to be easy. I don't claim to know how to do this myself.

I would add that this first attempt appears that it requires about twice the processing time as a single call to plot3d. I say this because every call generates the plot3d object, then decides to either call implicitplot3d or plot3d (again). A simple improvement in efficiency can be achieved with the following:

newplot3dA := proc(a,b,c,d)
local p;
p := plot3d(a,b,c);
if has( op([1,3],p), HFloat(undefined) )
then plots:-implicitplot3d( a^2=z^2, b,c,d );
else p;
end if;
end proc;

This avoids the use of the StringTools package, the type conversions, and a second call to plot3d. It does not fix any of the functionality issues.

A real solution will almost certainly not require a full call to plot3d to get started. It should be possible to do some quick processing to determine if there are going to be any issues.

The real challenge that I see is exactly what transformation needs to be applied to come up with the suitable implicit form for the surface. We'll start with z=a, but will then need to look for transformations of this that do not change the surface but will be easier to plot.

I should note that the use of z^2=a^2 is not perfect either as this also includes z=-a. To see this, change the z range to include some negative values (z=-1..6 or z=-6..6). The correct output should still be only the top half of the sphere.

This is not going to be easy - but could be very beneficial. I hope our interest will motivate Maplesoft to commit some resources to it. I think this has the potential to be useful throughout their range of products, including MapleSim.

Doug

@Christopher2222 Implicit plots can be hard, and expensive to create.

The basic algorithm is to try to find a point "on" the curve/surface and then to track nearby points. Of course, weird things can happen - the curve/surface can separate into multiple pieces (think about x^2=y^2 in the plane) or the curve/surface could come in more than one piece (or be the empty set). A true implicit plot has to account for all of these (and more). To do this for every plot could be very wasteful - think also about creating 3d animations.

Whether this functionality is default or optional is not important until this feature is implemented. If it's good enough, fast enough, and doesn't use too many resources then we can discuss whether it's the default.

There is probably some middle ground as well. I hope this discussion encourages those who know more about the inner workings of the plot system to think about ways to improve upon what we currently have available to us through Maple 16.

Doug

@Christopher2222 Implicit plots can be hard, and expensive to create.

The basic algorithm is to try to find a point "on" the curve/surface and then to track nearby points. Of course, weird things can happen - the curve/surface can separate into multiple pieces (think about x^2=y^2 in the plane) or the curve/surface could come in more than one piece (or be the empty set). A true implicit plot has to account for all of these (and more). To do this for every plot could be very wasteful - think also about creating 3d animations.

Whether this functionality is default or optional is not important until this feature is implemented. If it's good enough, fast enough, and doesn't use too many resources then we can discuss whether it's the default.

There is probably some middle ground as well. I hope this discussion encourages those who know more about the inner workings of the plot system to think about ways to improve upon what we currently have available to us through Maple 16.

Doug

I knew this, but was limiting myself to using plot3d.

What would be truly impressive is if the plot3d command had an optional argument, maybe implicit=true (or just implicit) that would instruct Maple to use an adaptive grid for creating the plot. It would not be a problem to get Maple to interpret the expression in the first argument as the surface z=. But I doubt this would produce the plot obtained by Alejandro (above). What Maple would have to do is to convert z=sqrt(25-x^2-y^2) to, at least, z^2=25-x^2-y^2. This is not difficult to see in this case, but it's not difficult to conjure up examples where it's not at all obvious what form would produce the best picture.

I think this would be a well received - and easily marketed - improvement. I hope there is someone who can put my ideas into practice - or to tell me why it's hopeless.

To what extent is it reasonable to expect (or even allow) Maple to look for alternate coordinate systems in which to produce the 3D plot?

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 knew this, but was limiting myself to using plot3d.

What would be truly impressive is if the plot3d command had an optional argument, maybe implicit=true (or just implicit) that would instruct Maple to use an adaptive grid for creating the plot. It would not be a problem to get Maple to interpret the expression in the first argument as the surface z=. But I doubt this would produce the plot obtained by Alejandro (above). What Maple would have to do is to convert z=sqrt(25-x^2-y^2) to, at least, z^2=25-x^2-y^2. This is not difficult to see in this case, but it's not difficult to conjure up examples where it's not at all obvious what form would produce the best picture.

I think this would be a well received - and easily marketed - improvement. I hope there is someone who can put my ideas into practice - or to tell me why it's hopeless.

To what extent is it reasonable to expect (or even allow) Maple to look for alternate coordinate systems in which to produce the 3D plot?

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

Think about what you are asking Maple to do. You want Maple to plot a function on a rectangle. To comply with your request it is natural to put a grid on the domain and to sample the function at these points. At some of these points the function value will be complex. How do you expect Maple to deal with these points? If Maple makes too many (any) assumptions, it's likely that some subset of users will not like these assumptions. So, Maple does nothing - it simply does not display anything when the function value is not a real number.

Thinking about this suggests some workarounds:

f := `if`(x^2+y^2>25,0,sqrt(25-x^2-y^2)):
plot3d(f,x=-6..6,y=-6..6,axes=box);

plot3d(`if`(x^2+y^2>25,0,sqrt(25-x^2-y^2)),x=-6..6,y=-6..6,axes=box)

 

You might ask Maple to automatically detect and track these boundaries. I believe this is not the default because it could significantly slow down processing.

It would, however, be nice if there could be a feature, like discont=true for plot, that could turn on this extra processing. (I know this example does not involve a discontinuity. I use this example for descriptive purposes only.)

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
3 4 5 6 7 8 9 Last Page 5 of 76