Ask Your Question
1

Plotting a line

asked 2017-11-08 08:31:27 +0100

pmg gravatar image

I have

x,y = var('x y')

f = (2x + 3y == 0)

How do I plot it

plot(f) gives the error:

Traceback (click to the left of this block for traceback) ... ValueError: Variable 'y' not found

And since it complained about y, why didn't it complain about x? Also, where would I find the docs for this question?

And yes, I am a beginner at sage

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-11-08 11:01:26 +0100

tmonteil gravatar image

The plot will work if you provide a function:

sage: x = SR.var('x')
sage: f = -2*x/3
sage: plot(f,-1,1)

In your case, f is an equation, so you need to use implicit_plot as follows:

sage: x,y = SR.var('x y')
sage: f = (2*x + 3*y == 0)
sage: implicit_plot(f,(-1,1),(-1,1))
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: 2017-11-08 08:27:48 +0100

Seen: 276 times

Last updated: Nov 08 '17