TExcelTAD
Home › Algebra › Graphing Quadratic Equations

Graphing Quadratic Equations

To sketch a parabola you do not need dozens of points. Five well-chosen features, the direction of opening, the vertex, the axis of symmetry, the yy-intercept and the xx-intercepts, pin the curve down. This lesson turns them into a step-by-step method and then uses it to design the jump of a platformer character.

Five steps

For y=ax2+bx+cy = ax^2 + bx + c:

  1. Direction: a>0a > 0 opens up, a<0a < 0 opens down.
  2. Vertex: h=−b2ah = -\frac{b}{2a}, k=the y-value at hk = \text{the } y\text{-value at } h. The axis of symmetry is the line x=hx = h.
  3. yy-intercept: (0,c)(0, c).
  4. Mirror point: the yy-intercept reflected across the axis, (2h,c)(2h, c).
  5. xx-intercepts: solve ax2+bx+c=0ax^2 + bx + c = 0 (by factoring or with the quadratic formula). There may be two, one or none.

Plot these points and draw a smooth U through them.

A worked example

Graph y=x2−4x−5y = x^2 - 4x - 5.

1.a=1>0→opens upward, vertex is a minimum2.h=−(−4)2⋅1=2,k=4−8−5=−9vertex (2,−9), axis x=23.x=0→y-intercept (0,−5)4.mirror of (0,−5) across x=2→(4,−5)5.x2−4x−5=(x−5)(x+1)→x-intercepts (−1,0) and (5,0)\begin{aligned} &\text{1.}\quad a = 1 > 0 && \to \text{opens upward, vertex is a minimum} \\ &\text{2.}\quad h = \frac{-(-4)}{2 \cdot 1} = 2,\quad k = 4 - 8 - 5 = -9 && \text{vertex } (2, -9),\ \text{axis } x = 2 \\ &\text{3.}\quad x = 0 && \to y\text{-intercept } (0, -5) \\ &\text{4.}\quad \text{mirror of } (0, -5) \text{ across } x = 2 && \to (4, -5) \\ &\text{5.}\quad x^2 - 4x - 5 = (x - 5)(x + 1) && \to x\text{-intercepts } (-1, 0) \text{ and } (5, 0) \end{aligned}

The xx-intercepts are symmetric about the axis too: −1 and 5 are both 3 units from x=2x = 2. That is a quick check on your arithmetic.

python · try it yourself
import numpy as np
import matplotlib.pyplot as plt

a, b, c = 1, -4, -5
h = -b / (2 * a)
k = a * h**2 + b * h + c
roots = np.roots([a, b, c])

x = np.linspace(-2, 6, 200)
plt.figure(figsize=(6, 4))
plt.plot(x, a * x**2 + b * x + c, label="y = x² − 4x − 5")
plt.axvline(h, linestyle="--", color="gray", label=f"axis x = {h:g}")
plt.plot([h], [k], "o", color="tab:red", label=f"vertex ({h:g}, {k:g})")
plt.plot([0, 2 * h], [c, c], "s", color="tab:green", label="y-intercept and mirror")
plt.plot(roots, [0, 0], "^", color="tab:purple", label="x-intercepts")
plt.axhline(0, color="black", linewidth=0.8)
plt.grid(True, alpha=0.3); plt.legend(fontsize=8)
plt.show()
print("vertex:", (h, k), " roots:", sorted(float(r) for r in roots))
vertex: (2.0, -9.0)  roots: [-1.0, 5.0]

Range and extreme values

Because the vertex is the turning point, it gives the smallest or largest yy-value:

aa Vertex is Range of yy
a>0a > 0 minimum y≥ky \ge k
a<0a < 0 maximum y≤ky \le k

For y=x2−4x−5y = x^2 - 4x - 5 the range is y≥−9y \ge -9. On a limited interval of xx, the extreme values occur either at the vertex (if it is inside the interval) or at the interval's ends. That is how you answer "what is the highest point of this arc?" or "what is the least cost?" without calculus.

In software: a platformer jump

Under constant gravity gg, a character who jumps with upward speed v0v_0 has height

y(t)=v0⋅t−12⋅g⋅t2y(t) = v_0 \cdot t - \tfrac{1}{2} \cdot g \cdot t^2

a downward parabola in tt. Its vertex is at t=v0gt = \frac{v_0}{g} (the apex) with height v022g\frac{v_0^2}{2g}. Game designers usually think the other way round: "the jump should be 3 tiles high and reach the top in 0.4 s". Setting the vertex to (T,H)(T, H) gives two equations, v0=g⋅Tv_0 = g \cdot T and H=12⋅g⋅T2H = \frac{1}{2} \cdot g \cdot T^2, whose solution is

g=2HT2v0=2HTg = \frac{2H}{T^2} \qquad v_0 = \frac{2H}{T}

With H=3H = 3 tiles and T=0.4T = 0.4 s: g=60.16=37.5 tiles/s2g = \frac{6}{0.16} = 37.5\ \text{tiles/s}^2 and v0=60.4=15 tiles/sv_0 = \frac{6}{0.4} = 15\ \text{tiles/s}, so y(t)=15t−18.75t2y(t) = 15t - 18.75t^2.

python · try it yourself
H, T = 3.0, 0.4                     # design: 3 tiles high, apex after 0.4 s
g = 2 * H / T**2
v0 = 2 * H / T
print(f"gravity {g:g} tiles/s², jump speed {v0:g} tiles/s")

def height(t):
    return v0 * t - 0.5 * g * t * t

for t in [0.0, 0.2, 0.4, 0.6, 0.8]:
    print(f"t = {t:.1f} s   y = {height(t):.2f}")

speed_x = 5.0                       # tiles per second while running
print("jump length:", speed_x * 2 * T, "tiles")
# height as a function of horizontal distance: substitute t = x / speed_x
for x in [0, 1, 2, 3, 4]:
    print(f"x = {x}  y = {height(x / speed_x):.2f}")
gravity 37.5 tiles/s², jump speed 15 tiles/s
t = 0.0 s   y = 0.00
t = 0.2 s   y = 2.25
t = 0.4 s   y = 3.00
t = 0.6 s   y = 2.25
t = 0.8 s   y = 0.00
jump length: 4.0 tiles
x = 0  y = 0.00
x = 1  y = 2.25
x = 2  y = 3.00
x = 3  y = 2.25
x = 4  y = 0.00

The table shows the symmetry: the character is at 2.25 tiles both 0.2 s before and 0.2 s after the apex, and lands at t=2T=0.8t = 2T = 0.8 s. Running at 5 tiles/s, the arc over the ground is y=3x−0.75x2y = 3x - 0.75x^2, a parabola in xx with its vertex at (2,3)(2, 3) and landing point x=4x = 4. Level designers use exactly this curve to check that gaps can be jumped and ceilings are high enough. Many games then use a larger gg on the way down for a snappier fall, which joins two different parabolas at the apex. Real engines step the motion frame by frame; see Physics Integration in Game Loops and Integrators.

Exercises

Exercise 1: Sketch a downward parabola

Find the direction, vertex, yy-intercept and xx-intercepts of y=−x2+2x+8y = -x^2 + 2x + 8.

Answer

Opens down; vertex (1,9)(1, 9); yy-intercept (0,8)(0, 8); xx-intercepts (−2,0)(-2, 0) and (4,0)(4, 0).

Solution
a=−1<0→opens downwardh=−22⋅(−1)=1, k=−1+2+8=9x=0→y=8; mirror (2,8)−x2+2x+8=−(x2−2x−8)=−(x−4)(x+2)=0→x=4 or x=−2\begin{aligned} &a = -1 < 0 \to \text{opens downward} \\ &h = \frac{-2}{2 \cdot (-1)} = 1,\ k = -1 + 2 + 8 = 9 \\ &x = 0 \to y = 8;\ \text{mirror } (2, 8) \\ &-x^2 + 2x + 8 = -(x^2 - 2x - 8) = -(x - 4)(x + 2) = 0 \to x = 4 \text{ or } x = -2 \end{aligned}

Check: −2 and 4 are both 3 units from the axis x=1x = 1.

Exercise 2: No x-intercepts

Graph y=2x2+4x+5y = 2x^2 + 4x + 5. Why does it have no xx-intercepts?

Answer

Vertex (−1,3)(-1, 3), yy-intercept (0,5)(0, 5), mirror (−2,5)(-2, 5). It opens upward and its lowest point is at y=3>0y = 3 > 0, so it never reaches the xx-axis.

Solution
h=−42⋅2=−1, k=2−4+5=3a>0, minimum value 3>0→no x-intercepts(discriminant: 16−40=−24<0, the same conclusion)\begin{aligned} &h = \frac{-4}{2 \cdot 2} = -1,\ k = 2 - 4 + 5 = 3 \\ &a > 0,\ \text{minimum value } 3 > 0 \to \text{no } x\text{-intercepts} \\ &(\text{discriminant: } 16 - 40 = -24 < 0,\ \text{the same conclusion}) \end{aligned}

Exercise 3: Highest and lowest on an interval

For y=(x−3)2+1y = (x - 3)^2 + 1 with 0≤x≤40 \le x \le 4, find the smallest and the largest value of yy.

Answer

Smallest 1 (at x=3x = 3), largest 10 (at x=0x = 0).

Solution

The vertex x=3x = 3 is inside the interval, so the minimum is k=1k = 1. The maximum is at one of the ends: y(0)=9+1=10y(0) = 9 + 1 = 10, y(4)=1+1=2y(4) = 1 + 1 = 2. So the maximum is 10.

python · try it yourself
ys = {x: (x - 3)**2 + 1 for x in [0, 3, 4]}
print(ys, min(ys.values()), max(ys.values()))
{0: 10, 3: 1, 4: 2} 1 10

Exercise 4: Design a short hop

A character's short hop should be 2 tiles high and reach its apex after 0.25 s. Compute gg and v0v_0, and check that the height at t=0.25t = 0.25 s is 2.

Answer

g=64 tiles/s2g = 64\ \text{tiles/s}^2, v0=16 tiles/sv_0 = 16\ \text{tiles/s}; y(0.25)=2y(0.25) = 2.

Solution
g=2⋅20.252=40.0625=64v0=2⋅20.25=16y(0.25)=16⋅0.25−32⋅0.0625=4−2=2 ✓\begin{aligned} g &= \frac{2 \cdot 2}{0.25^2} = \frac{4}{0.0625} = 64 \\ v_0 &= \frac{2 \cdot 2}{0.25} = 16 \\ y(0.25) &= 16 \cdot 0.25 - 32 \cdot 0.0625 = 4 - 2 = 2\ \checkmark \end{aligned}
python · try it yourself
H, T = 2, 0.25
g, v0 = 2 * H / T**2, 2 * H / T
print(g, v0, v0 * T - 0.5 * g * T**2)
64.0 16.0 2.0

Exercise 5: Clear the block?

With the arc y=3x−0.75x2y = 3x - 0.75x^2 from the lesson (xx in tiles from the take-off point), can the character clear a block 2 tiles high that spans from x=1x = 1 to x=3x = 3?

Answer

Yes: over the block the arc is never lower than 2.25 tiles.

Solution

The arc opens downward with its vertex at x=2x = 2, inside the block's span, so its lowest points over [1,3][1, 3] are at the ends:

y(1)=3−0.75=2.25y(3)=9−6.75=2.25min⁡ over the block=2.25>2→cleared, with 0.25 tiles to spare\begin{aligned} y(1) &= 3 - 0.75 = 2.25 \\ y(3) &= 9 - 6.75 = 2.25 \\ \min \text{ over the block} &= 2.25 > 2 \to \text{cleared, with } 0.25 \text{ tiles to spare} \end{aligned}

Test yourself

The yy-intercept of a parabola is (0,6)(0, 6) and its axis of symmetry is x=2x = 2. Which other point must be on the curve?

  1. (2,6)(2, 6)
  2. (−2,6)(-2, 6)
  3. (4,6)(4, 6)
  4. (6,0)(6, 0)

What is the range of y=−2(x+1)2+5y = -2(x + 1)^2 + 5?

  1. y≥5y \ge 5
  2. y≤5y \le 5
  3. y≤−1y \le -1
  4. all real numbers

A jump should reach height HH at time TT. Which gravity value does that require?

  1. g=HTg = \frac{H}{T}
  2. g=2HT2g = \frac{2H}{T^2}
  3. g=H⋅T2g = H \cdot T^2
  4. g=T22Hg = \frac{T^2}{2H}