ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 06 Aug 2015 04:54:13 +0200How to plot a parabola (conic): y²=4axhttps://ask.sagemath.org/question/28761/how-to-plot-a-parabola-conic-y24ax/I'm learning about conics, specifically parabolas, and I'd like to plot them. I already know how to do plot(x^2)), but what about y²=4ax ? I understand that representation is a relation, not a function, so that probably eliminates plot(f(x)). But, I'm stuck on how I might plot that so-called "general form" of a parabola.
Thanks!Thu, 06 Aug 2015 01:57:59 +0200https://ask.sagemath.org/question/28761/how-to-plot-a-parabola-conic-y24ax/Answer by dazedANDconfused for <p>I'm learning about conics, specifically parabolas, and I'd like to plot them. I already know how to do plot(x^2)), but what about y²=4ax ? I understand that representation is a relation, not a function, so that probably eliminates plot(f(x)). But, I'm stuck on how I might plot that so-called "general form" of a parabola.</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/28761/how-to-plot-a-parabola-conic-y24ax/?answer=28762#post-id-28762You could try plotting it as two functions but implicit_plot is the natural choice. The documentation is [here](http://doc.sagemath.org/html/en/reference/plotting/sage/plot/contour_plot.html#sage.plot.contour_plot.implicit_plot). This simple code illustrates how it could be done, given a specific value of a:
x, y = var('x,y')
a=1.1
implicit_plot(y^2==4*a*x, (x,-2,10), (y,-8,8))
Note the double equal signs. You can run the code in any Sage Cell Server, such as [here](https://sagecell.sagemath.org/), to check the result.
Plotting it as two functions:
a=1.1
A = plot(2*sqrt(a*x), (x, -2, 10))
B = plot(-2*sqrt(a*x), (x, -2, 10))
(A+B).show()
and with a little complaining Sage plots over values that avoids problems with the domain.Thu, 06 Aug 2015 04:54:13 +0200https://ask.sagemath.org/question/28761/how-to-plot-a-parabola-conic-y24ax/?answer=28762#post-id-28762