Ask Your Question
0

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

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

Hi all

I can understand the following somewhat surprising result :

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

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)  
4

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
1

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

kcrisman gravatar image

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

sage: var('y')
y
sage: min(x,y)
x
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

Comments

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

Laurent Claessens gravatar imageLaurent Claessens ( 2012-03-22 03:53:15 +0100 )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

Stats

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

Seen: 793 times

Last updated: Mar 21 '12