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

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 close merge delete

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).

Sort by » oldest newest most voted

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)


more

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))

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.

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.

more

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)

more