Ask Your Question
0

Graph based on y value as the input, and x as the output?

asked 2013-07-01 06:39:49 -0600

bxdin gravatar image

I need to identify the vertex of the following parabola: 3x-7 = y^2-5y

According to the book's author, since this contains a y^2 term rather than an x^2 term; I must obtain an end result with the standard form x = a(y - k)^2 + h

The answer, i.e. vertex, is (1/4, 5/2)

I did the following in sage 5.9, and as you can see the vertex point isn't located at the parabola, since the x in the 1st statement's equation, should be y. But sage says y is undefined:

p1 = plot( (1/3)*((x - 5/2)^2) + 1/4, (x,-15, 15), ymin =-5 , ymax = 25)
p3 = point((1/4, 5/2), size = 25)
p0 = p1 + p3
show(p0)

Is it possible for Sage to graph the equation based f(y), as opposed to the standard f(x), so i can see the vertex match up with the parabola.

edit retag flag offensive close merge delete

Comments

To fix the undefinedness issue, use `var('y')` before your code (we ask the user to define all variables other than `x` to avoid ambiguity).

kcrisman gravatar imagekcrisman ( 2013-07-01 07:02:35 -0600 )edit

3 answers

Sort by ยป oldest newest most voted
2

answered 2013-07-01 09:00:19 -0600

Martin Flashman gravatar image

Try using implicit_plot so you don't have to solve the equation for y in terms of x.

f = lambda x,y:y^2-3*x-5*y+7
p1=implicit_plot(f, (-4, 4), (-2, 6))
p2= point((1/4, 5/2), size = 45, color='red')
p0=p1+p2
show(p0)

This will do it... you can add your own features.

edit flag offensive delete link more

Comments

Thanks. Unfortunately implicit plot doesn't draw lines across the 0 values of the x & y axis. I was able to manually implement a line to show case the x-axis, but I can't get it to display 1 for the y-axis: p3 works, but p4= doesn't display anything. p3= plot(0, (x, -10, 10), ymin=-10, ymax=6) ....... ...... g = lambda x,y: 0 p4 = implicit_plot(g, (-10, 10), (-10, 6))

bxdin gravatar imagebxdin ( 2013-07-01 22:00:16 -0600 )edit

Also I can't perform substitution with the lambda formula :(.......: f = lambda x,y: y^2 + 3*y + 5*x + 2 f(y)= f.subs(y=y) f(13/10) ....Basically, I'm trying to plot the directrix on the graph as well.

bxdin gravatar imagebxdin ( 2013-07-01 22:11:05 -0600 )edit
2

answered 2013-07-02 15:10:18 -0600

calc314 gravatar image

updated 2013-07-02 15:11:36 -0600

Just as a note here, you don't need to use a lambda function here to get implicit plots to work. You will need to define y as a variable first, though. So, the code would be:

var('y')
f = y^2-3*x-5*y+7
Yax = x
Xax = y
SYMAXIS = y-5/2
p1=implicit_plot(f, (x,-4, 4), (y,-2, 6))
p2= point((1/4, 5/2), size = 45, color='red')
p3=implicit_plot(Yax,  (x,-4, 4), (y,-2, 6),color='black')
p4=implicit_plot(Xax,  (x,-4, 4), (y,-2, 6),color='black')
p5=implicit_plot(SYMAXIS,  (x,-4, 4), (y,-2, 6),color='green')
p0=p1+p2+p3+p4+p5 
show(p0)

This definition of your function f will also allow you to do the substitutions that you want.

edit flag offensive delete link more
1

answered 2013-07-02 10:39:03 -0600

Martin Flashman gravatar image

Here I've displayed the X and Y axes as well as the axis of symmetry. I'm not sure what you are trying to do using "substitution".

f = lambda x,y:y^2-3*x-5*y+7
Yax = lambda x,y:x
Xax = lambda x,y:y
SYMAXIS = lambda x,y:y-5/2
p1=implicit_plot(f, (-4, 4), (-2, 6))
p2= point((1/4, 5/2), size = 45, color='red')
p3=implicit_plot(Yax, (-4, 4), (-2, 6),color='black')
p4=implicit_plot(Xax, (-4, 4), (-2, 6),color='black')
p5=implicit_plot(SYMAXIS, (-4, 4), (-2, 6),color='green')
p0=p1+p2+p3+p4+p5 
show(p0)
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

Stats

Asked: 2013-07-01 06:39:49 -0600

Seen: 442 times

Last updated: Jul 02 '13