I have a function of two variables: enter image description here

With some values enter image description here

Now I have to plot this, so that tha values of U are between -5 and 0. How do I do this? (Note: It's not the values of x and y that need to be between -5 and 0.)



2 Answers 2


A nice smooth surface can be obtained simply by using the plot3d command along with your operator U as given.



M1:=1: M2:=1: a:=5: omega:=0.2:

The view option will restrict the z-range displayed. So it is easy to constrain it to z=-5..0.

plot3d(U, -20..20, -20..20, view=-5..0, labels=[x,y,z]);

enter image description here

But you could also compute the x- and y-ranges for the plot3d call so that they are tightly constrained by the lower value of z=-5. (There are various ways to compute those tight bounds.)


                     xlo := -13.1019759104502107


                     xhi := 18.1019759104502107


                     ylo := -15.6100765315323216


                     yhi := 15.6100765315323216

plot3d(U, xlo..xhi, ylo..yhi, view=-5..0,labels=[x,y,z]);

enter image description here

  • $\begingroup$ thanks for your nice and correct remarks. Honestly, what I did was what I know about the request. I am not professional as you always do here for various kind of questions tagged by Maple. :-) I changed some points in the plot to be good looking and that's why you saw some inconsistent factors between codes and plot. Any way thanks again. Indeed, your complete approach should have been accepted. :-) $\endgroup$
    – Mikasa
    Jan 11, 2014 at 8:38
  • $\begingroup$ This works brilliantly, thanks a lot! $\endgroup$
    – The Oddler
    Jan 11, 2014 at 10:48

Here are the required codes in Maple:

 [> f := (m1, m2, w, a)-> -m1/sqrt(x^2+y^2)-m2/sqrt((x-a)^2+y^2)-.5*w^2*((x-m2*a/(m1+m2))^2+y^2):
 [> g:=(x,y)-> f(1,2,0.2,5):
    with(plots): implicitplot3d(z=g(x,y),x=-10..10,y=-10..10,z=-5..0);

enter image description here

  • $\begingroup$ Can you recommend a good book for learning Maple? Nice Plot +1 $\endgroup$
    – Amzoti
    Jan 11, 2014 at 3:14
  • $\begingroup$ Differential Equation with Maple by B. R. Hunt is a good one in our interest. $\endgroup$
    – Mikasa
    Jan 11, 2014 at 3:25
  • 1
    $\begingroup$ The image shown is not what that Maple code produces, for the following reasons: the x- and y-ranges in the code are -10..10 but the plot shows about -50..50, and the plot appears to be style=patchnogrid, and implicitplot3d will not produce such a smooth surface by default (you'd have to add some option, eg grid=[50,50,50] or some other option). Also, M2 was stated as being 1, rather than 2, but that's a quibble. More relevant is that implicitplot3d is an expensive a slow way to produce a smooth surface for this example. More simple is just to use the plot3d command. $\endgroup$
    – acer
    Jan 11, 2014 at 8:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .