Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I don't have Sage 4.7 around but I'm a little surprised that it works there. The issue is that V and W aren't two different ways of expressing the same kind of thing, they're two different things.

V is a Python function, W is a Sage function.

sage: parent(V)
<type 'function'>
sage: type(V)
<type 'function'>
sage: V
<function V at 0x10f423500>
sage: parent(W)
Callable function ring with arguments (x, y)
sage: type(W)
<type 'sage.symbolic.expression.Expression'>
sage: W
(x, y) |--> x + y + sqrt(abs(-x^2 - y^2 + 1))

And when you call them with x and y as arguments:

sage: W(x,y)
x + y + sqrt(abs(-x^2 - y^2 + 1))
sage: V(x,y)
20

W returns an Expression and V returns a number. This happens because V(x,y) is evaluated immediately in the contour_plot line, it decides that it can't prove (x**2+y**2 <1) is true (which it isn't: x and y could be anything, as far as it knows) and so it returns 20 on the other branch. You're basically asking for

r+=contour_plot(20,px,py,contours=[1.50],fill=false,cmap=["magenta"])

If you want to pass the Python function itself, you can use

r+=contour_plot(V,px,py,contours=[1.50],fill=false,cmap=["magenta"])

which gave me (in 4.8):

image description