randFromArray([ -2, -1, -0.5, -0.25, 0.25, 0.5, 1, 2 ]) randRangeNonZero( -4, 4 )/8 randRangeNonZero( -4, 4 )/8 Y1 + 1 / (4 * A) Y1 - 1 / (4 * A) fractionReduce.apply(KhanUtil, toFraction(A, 0.001)) fractionReduce.apply(KhanUtil, toFraction(X1, 0.001)) fractionReduce.apply(KhanUtil, toFraction(Y1, 0.001)) fractionReduce.apply(KhanUtil, toFraction(VERTEX_Y, 0.001)) fractionReduce.apply(KhanUtil, toFraction(DIR_Y, 0.001))

First, find the focus and directrix of the parabola by moving the orange point and line to their correct positions. Then use that information to find the equation of the parabola.

graph.A = A; graph.X1 = X1; graph.Y1 = Y1; initAutoscaledGraph( [ [ -2.5, 2.5 ], [ -2.5, 2.5 ] ], {} ); addMouseLayer(); graph.directrix = addMovableLineSegment({ coordA: [0, -1], coordZ: [1, -1], snapY: 0.125, vertical: false, extendLine: true, normalStyle: { "stroke": KhanUtil.ORANGE, "stroke-width": 2 }, highlightStyle: { "stroke": KhanUtil.ORANGE, "stroke-width": 4 } }); graph.directrix.onMove = function( x, y ) { var coord = this.coordA[1]; $("#directrix-label").html( "<code>" + fractionReduce.apply(KhanUtil, toFraction(coord, 0.001)) + "</code>" ).tex(); }; graph.vertex = addMovablePoint({ coordX: 0, coordY: 1, snapX: 0.125, snapY: 0.125, }); graph.vertex.onMove = function( coordX, coordY ) { $("#focus-x-label").html( "<code>" + fractionReduce.apply(KhanUtil, toFraction(coordX, 0.001)) + "</code>" ).tex(); $("#focus-y-label").html( "<code>" + fractionReduce.apply(KhanUtil, toFraction(coordY, 0.001)) + "</code>" ).tex(); }; graph.func = addInteractiveFn( function(x) { return ( A * ( x - X1 ) * ( x - X1 ) ) + Y1; }, {}); doParabolaInteraction( graph.func, graph.vertex, graph.directrix );

The two green line segments you see when you point to the parabola are always the same length as each other. Use them to check that you've found the right focus and directrix.

[ graph.vertex.coord, graph.directrix.coordA[1] ]
if (_.isEqual(guess, [[0, 1], -1])) { return ""; } return guess[0][0] === X1 && guess[0][1] === Y1 + 1 / (4 * A) && guess[1] === Y1 - 1 / (4 * A)
graph.vertex.setCoord( guess[0] ); graph.directrix.coordA = [0, guess[1]]; graph.directrix.coordZ = [1, guess[1]]; graph.directrix.transform();

Focus: `(``0``,\quad` `1``)`

Directrix: `y = {}``-1`

Equation of the parabola:
`y - {}`Y1`{} = {}`A`(x - {}`X1`)^2`

All points on a parabola are equidistant from the focus and directrix. There is only one place to put the orange focus point and directrix line where this is true.

The focus is `(PRETTY_X1, PRETTY_FOCUS_Y)` and the directrix is `y = PRETTY_DIR_Y`

The equation for a parabola is `y - y_1 = a (x - x_1)^2`, where `x_1` and `y_1` are the coordinates of the vertex of the parabola (halfway between the focus and directrix).

`x_1` is the same as the `x` coordinate of the focus. `y_1` is at the midpoint of `PRETTY_FOCUS_Y` and `PRETTY_DIR_Y`.

So `x_1 = PRETTY_X1`. And `y_1 = \dfrac{PRETTY_FOCUS_Y + PRETTY_DIR_Y}{2} = PRETTY_Y1`.

The leading coefficient `a` in the equation `y - y_1 = a (x - x_1)^2` indicates how "wide" and in what direction the parabola opens. It's always the reciprocal of `2` times the distance from the directrix to the focus.

`a = \dfrac{1}{2 \times (PRETTY_FOCUS_Y {-} PRETTY_DIR_Y)} = PRETTY_A`

So the equation of the parabola is `y - PRETTY_Y1 = PRETTY_A(x - PRETTY_X1)^2`.