Ask Your Question
0

Error when making it a function

asked 2018-03-19 16:35:06 +0100

Julien gravatar image

updated 2018-03-19 18:24:43 +0100

kcrisman gravatar image

This code works for my 3d graph.

But when I turn it into a function for an @interact, it does not work anymore.

How can I fix this? Thanks.

Edit: here is the code:

x, y, z = var('x, y, z')
@interact
def graphe(f = input_box(default=cos(y), label="$f(x,y)$"), r = input_box(default=10, label="$r$")):
    G = implicit_plot3d(z==f(x,y), (x, -r, r), (y, -r, r), (z, -r, r), plot_points=30, color='orange', mesh=1, opacity=.7)
    show(G, spin=1)
edit retag flag offensive close merge delete

Comments

Please provide the code and instructions to reproduce.

slelievre gravatar imageslelievre ( 2018-03-19 17:03:30 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-03-19 18:24:17 +0100

kcrisman gravatar image

updated 2018-03-19 18:25:08 +0100

Try adding the line

f(x,y) = f

so that Sage knows it is a function of two variables; your syntax can't work because f(x,y) doesn't work from the input box this way. Here is a live example.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-03-19 16:35:06 +0100

Seen: 287 times

Last updated: Mar 19 '18