Ask Your Question

min(x,y)=x ... and then plot3d f(x,y)=min(x,y)

asked 2012-03-21 16:05:43 +0200

Hi all

I can understand the following somewhat surprising result :

sage: var('x,y')
(x, y)
sage: min(x,y)

A friend of mine wants to plot3d the function that a human should write f(x,y)=min(|x|,|y|)

what she does is

sage: f(x,y)=min(abs(x),abs(y))
sage: plot3d(f,(x,-2,2),(y,-2,2))

of course, it does not produce the expected result because of what I said in introduction about min(x,y). By the way :

sage: f(4,1)  

So ... well ... what do I have to say to her ? What is the best way to plot a function (in the math sense of the term) when it cannot be managed by a function (in the Sage sense of the term).

The following works :

sage: f=lambda x,y:min(abs(x),abs(y))

I guess that

def f(x,y):
   return min(abs(x),abs(y))

will also work.

So my questions are :

  1. why min(x,y)=x ?
  2. how can I "predict" if such or such function will not work using the simple declaration f(x,y)=blahblah ?
  3. what is the best way to deal with such cases ?

Thanks for any help

have a good night

Laurent Claessens (on the night timezone :) )

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-03-21 16:28:20 +0200

kcrisman gravatar image

I can't find this, but I'm pretty sure there is another question with this on

sage: var('y')
sage: min(x,y)
sage: min_symbolic(x,y)
min(x, y)

I think if you use the latter, all should be well. I hope? Don't have time to try now. Good luck!

edit flag offensive delete link more


Yes, `min_symbolic` is the answer. Thanks :)

Laurent Claessens gravatar imageLaurent Claessens ( 2012-03-22 03:53:15 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-03-21 16:05:43 +0200

Seen: 750 times

Last updated: Mar 21 '12