# How do I correct this 3d Function plot error?

In recent work trying to visualize the graph of a function from RP^1 to RP^1 on the torus, the code I used gave a DeprecationWarning that I have not been able to interpret.

/home/sageserver/sage/sagecell-main/interact_sagecell.py:422: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...) See http://trac.sagemath.org/5930 for details. returned = f(args, *control_vals)

The graph also seemed to hang up-- though it now seems ok. Any assistance would be appreciated, THANKS.

https://sagecell.sagemath.org/?z=eJyN...

And here's the Code:

u, v ,t = var('u,v,t')
html( "<center> <b> <h2> Graph of $f : RP^1$ to $RP^1$ </h2></b>")
@interact
def map(f = x^2):
f1= ((3 + cos(v))*cos(u),(3 + cos(v))*sin(u),sin(v) )
f3=((3 + cos(2*arctan(f(2*tan(v / 2)) )))*cos( v ), (3 + cos(2*arctan(f(2*tan(v / 2)) )))*sin(v), sin(2*arctan(f(2*tan(v / 2)) )) )
p1= parametric_plot3d(  f1, (u, 0, 2*pi), (v, 0, 2*pi), color= "yellow")
p2=arrow3d( (0,0,-4),(0,0,4))
p3= parametric_plot3d( f3, (v, 0, 2*pi), color="red",thickness = 10 )
show(p1+p2+p3)

edit retag close merge delete

Sort by » oldest newest most voted

Just put

f(x) = f


toward the top of your main function. The point is that we have deprecated substituting in f = x^2 because of nasty things like g = x^2 + y - y where it's not clear whether g(1) should be about the y or the x. (You can search the Sage email lists for more looooong discussions about this.)

Here is a live example. Looks nice!

(Naturally, this does assume that x will be your variable.)

more