[Math] Algebraic solution for the intersection point(s) of two parabolas

linear algebra

I recently ran through an algebraic solution for the intersection point(s) of two parabolas $ax^2 + bx + c$ and $dx^2 + ex + f$ so that I could write a program that solved for them. The math goes like this:

$$
ax^2 – dx^2 + bx – ex + c – f = 0 \\
x^2(a – d) + x(b – e) = f – c \\
x^2(a – d) + x(b – e) + \frac{(b – e)^2}{4(a – d)} = f – c + \frac{(b – e)^2}{4(a – d)} \\
(x\sqrt{a – d} + \frac{b – e}{2\sqrt{a – d}})^2 = f – c + \frac{(b – e)^2}{4(a – d)} \\
(a – d)(x + \frac{b – e}{2(a – d)})^2 = f – c + \frac{(b – e)^2}{4(a – d)} \\
x + \frac{b – e}{2(a – d)} = \sqrt{\frac{f – c + \frac{(b – e)^2}{a – d}}{a – d}} \\
x = \pm\sqrt{\frac{f – c + \frac{(b – e)^2}{a – d}}{a – d}} – \frac{b – e}{2(a – d)} \\
$$

Then solving for $y$ is as simple as plugging $x$ into one of the equations.

$$
y = ax^2 + bx + c
$$

Is my solution for $x$ and $y$ correct? Is there a better way to solve for the intersection points?

Best Answer

You lost a factor $4$ somewhere. You can simply rewrite your problem as

$$(a-d)x^2+(b-e)x+(c-f)=0$$

and use the standard formula for a quadratic equation, i.e.

$$x=-\frac{b-e}{2(a-d)}\pm\sqrt{\frac{(b-e)^2}{4(a-d)^2}-\frac{c-f}{a-d}}$$

Before evaluating this equation, you need to check if $a-d=0$, in which case

$$x=\frac{f-c}{b-e}$$

In this case you of course need to check if $b-e=0$.