Alec Mihailovs

Dr. Aleksandrs Mihailovs

4475 Reputation

21 Badges

20 years, 73 days
Mihailovs, Inc.
Owner, President, and CEO
Tyngsboro, Massachusetts, United States

Social Networks and Content at Maplesoft.com

I received my Ph.D. from the University of Pennsylvania in 1998 and I have been teaching since then at SUNY Oneonta for 1 year, at Shepherd University for 5 years, at Tennessee Tech for 2 years, at Lane College for 1 year, and this year I taught at the University of Massachusetts Lowell. My research interests include Representation Theory and Combinatorics.

MaplePrimes Activity


These are replies submitted by Alec Mihailovs

@PatrickT 

Here is a simple example using the last 3d-plot on the ?plottools,getdata page.

First, in Maple, save that Array as a text file - something like

A:=plottools:-getdata(plot3d(sin(x+y), x=-1..1, y=-1..1))[-1]:
fprintf("mydata.txt","%f",A):
fclose("mydata.txt");

Then, assuming that you have Python with numpy and Mayavi installed, start Python and type (or save that as a script (with extension .py) and run Python on it,

from numpy import genfromtxt, mgrid
from enthought.mayavi import mlab
data=genfromtxt("mydata.txt")
x,y=mgrid[-1.:1.08:0.08,-1.:1.08:0.08]
s=mlab.surf(x,y,data)
mlab.show()

That will produce a window looking like that,

The plot can be rotated, colors and other properties edited clicking on the last button in the toolbar, and it can be saved by clicking on the next to it button in various formats (see the Mayavi help) - the default is png.

Alec

@PatrickT 

Here is a simple example using the last 3d-plot on the ?plottools,getdata page.

First, in Maple, save that Array as a text file - something like

A:=plottools:-getdata(plot3d(sin(x+y), x=-1..1, y=-1..1))[-1]:
fprintf("mydata.txt","%f",A):
fclose("mydata.txt");

Then, assuming that you have Python with numpy and Mayavi installed, start Python and type (or save that as a script (with extension .py) and run Python on it,

from numpy import genfromtxt, mgrid
from enthought.mayavi import mlab
data=genfromtxt("mydata.txt")
x,y=mgrid[-1.:1.08:0.08,-1.:1.08:0.08]
s=mlab.surf(x,y,data)
mlab.show()

That will produce a window looking like that,

The plot can be rotated, colors and other properties edited clicking on the last button in the toolbar, and it can be saved by clicking on the next to it button in various formats (see the Mayavi help) - the default is png.

Alec

@PatrickT 

Sure points can be plotted too. I could do the same example that you posted above if you post Maple code producing it, or something different - or just pointing to the corresponding example on the web.

I am also rather busy at the moment, but that shouldn't take long.

Python can be downloaded from their main site, and the best place for downloading additional math and science (and graphics)  packages (for Windows) is at that link.

Mayavi is in the ETS package, and you might be interested also in Matplotlib for 2D-graphics (with LaTeX). NumPy with MKL is absolutely necessary. SciPy might be also useful. There are a few other graphics packages there etc. Spyder provides a convenient IDE.

The Python community is extremely friendly (unlike any other programming community) and large.

Alec

@PatrickT 

Sure points can be plotted too. I could do the same example that you posted above if you post Maple code producing it, or something different - or just pointing to the corresponding example on the web.

I am also rather busy at the moment, but that shouldn't take long.

Python can be downloaded from their main site, and the best place for downloading additional math and science (and graphics)  packages (for Windows) is at that link.

Mayavi is in the ETS package, and you might be interested also in Matplotlib for 2D-graphics (with LaTeX). NumPy with MKL is absolutely necessary. SciPy might be also useful. There are a few other graphics packages there etc. Spyder provides a convenient IDE.

The Python community is extremely friendly (unlike any other programming community) and large.

Alec

@acer 

In Maple 15, evalhf is not needed for polynomials, but it is needed for sin and sqrt. In particular, in the example that I did (I don't repeat the code since it can be just copied from there.)

eval(A,sol[2]);

                                                     1/2
         -0.701281994102444 - sin(0.777194230546894 2    + 1)

and neither

evalf[20](%);
                        -1.5649359859449897444

nor

evalf[18](%%);
                         -1.56493598594498974

give the same value as in the NLPSolve answer, while evalhf does,

evalhf(%%%);
                         -1.56493598594498962

I don't think that you are being rude in the posts in this thread. I think that you are being patronizing, which is, probably, understandable (but would be more understandable if I knew who you are.) Also, I think that initially the post reording might gave you a wrong idea in the consequence in which all those messages were made.

Certainly, you have all my respect and I hope I didn't post anything that might look rude, too.

Thank you for good words about me,
Alec

@acer 

In Maple 15, evalhf is not needed for polynomials, but it is needed for sin and sqrt. In particular, in the example that I did (I don't repeat the code since it can be just copied from there.)

eval(A,sol[2]);

                                                     1/2
         -0.701281994102444 - sin(0.777194230546894 2    + 1)

and neither

evalf[20](%);
                        -1.5649359859449897444

nor

evalf[18](%%);
                         -1.56493598594498974

give the same value as in the NLPSolve answer, while evalhf does,

evalhf(%%%);
                         -1.56493598594498962

I don't think that you are being rude in the posts in this thread. I think that you are being patronizing, which is, probably, understandable (but would be more understandable if I knew who you are.) Also, I think that initially the post reording might gave you a wrong idea in the consequence in which all those messages were made.

Certainly, you have all my respect and I hope I didn't post anything that might look rude, too.

Thank you for good words about me,
Alec

I chuckled at the phrase on page iii:

Ironically, I should also thank
the creators of Maple, an expensive software package also used in my research.

Alec

@acer 

I didn't try to prove that evalhf is superior to evalf with higher digits setting - I just showed how to use it (with eval instead of subs.) It worked pretty well in the example that I did.

As far as I recall (I didn't check that though just now), but Maple libraries usually use something like evalf(..., d+2) instead of evalf[d+2](...). Are you saying that Maplesoft programmers are using the inferior version of evalf?

One advantage of using evalf(..., d) instead of evalf[d] is that that avoids the evalf bug which might be present in some Maple versions.

The numbers in the original post look like hardware floats.

Alec

PS I may be wrong though about the library code - just checked `evalf/sin` and there is evalf(evalf[Digits+2](... at the end of it. -Alec

PPS Just checked the ?evalf,details help page, and you are absolutely right - the 2 argument call is not mentioned in it. So the statement "This help page contains complete information about the evalf command." in the Basic Information section doesn't seem to be truthful. -Alec


@acer 

I didn't try to prove that evalhf is superior to evalf with higher digits setting - I just showed how to use it (with eval instead of subs.) It worked pretty well in the example that I did.

As far as I recall (I didn't check that though just now), but Maple libraries usually use something like evalf(..., d+2) instead of evalf[d+2](...). Are you saying that Maplesoft programmers are using the inferior version of evalf?

One advantage of using evalf(..., d) instead of evalf[d] is that that avoids the evalf bug which might be present in some Maple versions.

The numbers in the original post look like hardware floats.

Alec

PS I may be wrong though about the library code - just checked `evalf/sin` and there is evalf(evalf[Digits+2](... at the end of it. -Alec

PPS Just checked the ?evalf,details help page, and you are absolutely right - the 2 argument call is not mentioned in it. So the statement "This help page contains complete information about the evalf command." in the Basic Information section doesn't seem to be truthful. -Alec


@Gary Palmer 

The Classic Maple editor is limited because it is based on a rather old Star Division GmbH (1991-1994) software, which one can see in it's about box (in Help menu.)

The Standard Maple editor is limited because it runs in Java virtual machine - it is not a native application.

Alec

@Gary Palmer 

The Classic Maple editor is limited because it is based on a rather old Star Division GmbH (1991-1994) software, which one can see in it's about box (in Help menu.)

The Standard Maple editor is limited because it runs in Java virtual machine - it is not a native application.

Alec

@acer 

evalf[20] is the same as evalf(..., 20), which I mentioned in my (first) reply as well, and personally I prefer the version without square brackets.

I don't have Maple 10 to test what is working there. As far as I understood the question - it was that evaluating of A produces different results than given by NPSolve. While evalf[20] is more precize than simple evalf (if Digits set to a number less than 20), it still produces a different result. evalhf produces the same result if the calculations were done in the hardware floats.

In my second reply I just showed how to use the evalhf in this situation, replying to a comment that evalhf doesn't work with subs. It worked in Maple 15 in the example that I used. The rest - the comments about minimize(A) and local vs. global were just side comments related to that example, not to the original question. I added them later, by the way, just as a note to myself mostly. They were not very original, in general - this stuff is well known, but it was an interesting (for me) example of how that happens.

Alec

PS Perhaps, reordering the posts made that look confusing - it looks in the current ordering as if pagan replied first that evalf[20] is good and then I replied that evalhf is better. In reality, I replied first that both evalhf and evalf with higher setting of Digits can be used, then 3 hours later pagan posted that evalf[20] is good (like if I din't mention that before). Meanwhile, the original poster replied to my first answer that evalf is good, but not absolutely, and evalhf doesn't work with subs. Coming home and noticing that, I just showed how evalhf can be used, replying to that OP comment. -Alec

@acer 

evalf[20] is the same as evalf(..., 20), which I mentioned in my (first) reply as well, and personally I prefer the version without square brackets.

I don't have Maple 10 to test what is working there. As far as I understood the question - it was that evaluating of A produces different results than given by NPSolve. While evalf[20] is more precize than simple evalf (if Digits set to a number less than 20), it still produces a different result. evalhf produces the same result if the calculations were done in the hardware floats.

In my second reply I just showed how to use the evalhf in this situation, replying to a comment that evalhf doesn't work with subs. It worked in Maple 15 in the example that I used. The rest - the comments about minimize(A) and local vs. global were just side comments related to that example, not to the original question. I added them later, by the way, just as a note to myself mostly. They were not very original, in general - this stuff is well known, but it was an interesting (for me) example of how that happens.

Alec

PS Perhaps, reordering the posts made that look confusing - it looks in the current ordering as if pagan replied first that evalf[20] is good and then I replied that evalhf is better. In reality, I replied first that both evalhf and evalf with higher setting of Digits can be used, then 3 hours later pagan posted that evalf[20] is good (like if I din't mention that before). Meanwhile, the original poster replied to my first answer that evalf is good, but not absolutely, and evalhf doesn't work with subs. Coming home and noticing that, I just showed how evalhf can be used, replying to that OP comment. -Alec

That was very prompt!

Thank you!

Alec

That was very prompt!

Thank you!

Alec

1 2 3 4 5 6 7 Last Page 1 of 180