ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 02 Jul 2013 15:10:18 -0500Graph based on y value as the input, and x as the output?http://ask.sagemath.org/question/10307/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.Mon, 01 Jul 2013 06:39:49 -0500http://ask.sagemath.org/question/10307/graph-based-on-y-value-as-the-input-and-x-as-the-output/Comment by kcrisman for <p>I need to identify the vertex of the following parabola:
3x-7 = y^2-5y</p>
<p>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</p>
<p>The answer, i.e. vertex, is (1/4, 5/2)</p>
<p>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:</p>
<pre><code>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)
</code></pre>
<p>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.</p>
http://ask.sagemath.org/question/10307/graph-based-on-y-value-as-the-input-and-x-as-the-output/?comment=17408#post-id-17408To fix the undefinedness issue, use `var('y')` before your code (we ask the user to define all variables other than `x` to avoid ambiguity).Mon, 01 Jul 2013 07:02:35 -0500http://ask.sagemath.org/question/10307/graph-based-on-y-value-as-the-input-and-x-as-the-output/?comment=17408#post-id-17408Answer by Martin Flashman for <p>I need to identify the vertex of the following parabola:
3x-7 = y^2-5y</p>
<p>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</p>
<p>The answer, i.e. vertex, is (1/4, 5/2)</p>
<p>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:</p>
<pre><code>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)
</code></pre>
<p>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.</p>
http://ask.sagemath.org/question/10307/graph-based-on-y-value-as-the-input-and-x-as-the-output/?answer=15172#post-id-15172Here 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)Tue, 02 Jul 2013 10:39:03 -0500http://ask.sagemath.org/question/10307/graph-based-on-y-value-as-the-input-and-x-as-the-output/?answer=15172#post-id-15172Answer by Martin Flashman for <p>I need to identify the vertex of the following parabola:
3x-7 = y^2-5y</p>
<p>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</p>
<p>The answer, i.e. vertex, is (1/4, 5/2)</p>
<p>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:</p>
<pre><code>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)
</code></pre>
<p>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.</p>
http://ask.sagemath.org/question/10307/graph-based-on-y-value-as-the-input-and-x-as-the-output/?answer=15167#post-id-15167Try 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. Mon, 01 Jul 2013 09:00:19 -0500http://ask.sagemath.org/question/10307/graph-based-on-y-value-as-the-input-and-x-as-the-output/?answer=15167#post-id-15167Comment by bxdin for <p>Try using implicit_plot so you don't have to solve the equation for y in terms of x. </p>
<pre><code>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)
</code></pre>
<p>This will do it... you can add your own features. </p>
http://ask.sagemath.org/question/10307/graph-based-on-y-value-as-the-input-and-x-as-the-output/?comment=17395#post-id-17395Thanks. 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))Mon, 01 Jul 2013 22:00:16 -0500http://ask.sagemath.org/question/10307/graph-based-on-y-value-as-the-input-and-x-as-the-output/?comment=17395#post-id-17395Comment by bxdin for <p>Try using implicit_plot so you don't have to solve the equation for y in terms of x. </p>
<pre><code>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)
</code></pre>
<p>This will do it... you can add your own features. </p>
http://ask.sagemath.org/question/10307/graph-based-on-y-value-as-the-input-and-x-as-the-output/?comment=17394#post-id-17394Also 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.Mon, 01 Jul 2013 22:11:05 -0500http://ask.sagemath.org/question/10307/graph-based-on-y-value-as-the-input-and-x-as-the-output/?comment=17394#post-id-17394Answer by calc314 for <p>I need to identify the vertex of the following parabola:
3x-7 = y^2-5y</p>
<p>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</p>
<p>The answer, i.e. vertex, is (1/4, 5/2)</p>
<p>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:</p>
<pre><code>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)
</code></pre>
<p>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.</p>
http://ask.sagemath.org/question/10307/graph-based-on-y-value-as-the-input-and-x-as-the-output/?answer=15173#post-id-15173Just 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.
Tue, 02 Jul 2013 15:10:18 -0500http://ask.sagemath.org/question/10307/graph-based-on-y-value-as-the-input-and-x-as-the-output/?answer=15173#post-id-15173