1
$\begingroup$

I'm trying to define a quadratic that can pass through any 3 points. I've obviously done something wrong but can't figure out where. Any help would be appreciated.

$ ax_1^2 + bx_1 + c = y_1 $ $ ax_2^2 + bx_2 + c = y_2 $ $ ax_3^2 + bx_3 + c = y_3 $

Solve for C using the first equation

1$ ax_1^2 + bx_1 + c = y_1 $ 2$ ax_1^2 + bx_1 - y_1 = -c $ 3$ -ax_1^2 - bx_1 + y_1 = c $ 4$ c = -ax_1^2 - bx_1 + y_1 $

Now substitute C and solve be B using the second equation

5$ ax_2^2 + bx_2 + c = y_2 $ 6$ ax_2^2 + bx_2 - ax_1^2 - bx_1 + y_1 = y_2 $ 7$ a(x_2^2 - x_1^2) + b(x_2 - x_1) = y_2 - y_1 $ 8$ b(x_2 - x_1) = y_2 - y_1 - a(x_2^2 - x_1^2) $ 9$ b = \frac{y_2 - y_1 - a(x_2^2 - x_1^2)}{(x_2 - x_1)} $

Ok, now substitute B and C and solve A using the third equation

10$ ax_3^2 + bx_3 + c = y_3 $ $ ax_3^2 + bx_3 - ax_1^2 - bx_1 + y_1 = y_3 $

11$ ax_3^2 + x_3\left(\frac{y_2 - y_1 - a(x_2^2 - x_1^2)}{(x_2 - x_1)}\right) - ax_1^2 - x_1\left(\frac{y_2 - y_1 - a(x_2^2 - x_1^2)}{(x_2 - x_1)}\right) + y_1 = y_3 $

12$ ax_3^2 - ax_1^2 + \frac{x_3(y_2 - y_1) - x_3a(x_2^2 - x_1^2)}{x_3(x_2 - x_1)} + \frac{-x_1(y_2 - y_1) + x_1a(x_2^2 - x_1^2)}{-x_1(x_2 - x_1)} = y_3 - y_1 $

13$ ax_3^2 - ax_1^2 + \frac{-x_1x_3(y_2 - y_1) + x_1x_3a(x_2^2 - x_1^2)}{-x_1x_3(x_2 - x_1)} + \frac{-x_1x_3(y_2 - y_1)+ x_1x_3a(x_2^2 - x_1^2)}{-x_1x_3(x_2 - x_1)} = y_3 - y_1 $

14$ ax_3^2 - ax_1^2 + \frac{-x_1x_3(y_2 - y_1) + x_1x_3a(x_2^2 - x_1^2) - x_1x_3(y_2 - y_1) + x_1x_3a(x_2^2 - x_1^2)}{-x_1x_3(x_2 - x_1)} = y_3 - y_1 $

15$ ax_3^2 - ax_1^2 + \frac{(y_2 - y_1) - a(x_2^2 - x_1^2) + (y_2 - y_1) - a(x_2^2 - x_1^2)}{(x_2 - x_1)} = y_3 - y_1 $

16$ a(x_3^2 - x_1^2) + \frac{2(y_2 - y_1) - 2a(x_2^2 - x_1^2)}{(x_2 - x_1)} = y_3 - y_1 $

17$ a(x_3^2 - x_1^2) + \frac{2(y_2 - y_1)}{(x_2 - x_1)} + \frac{ -2a(x_2^2 - x_1^2) }{(x_2 - x_1)} = y_3 - y_1 $

18$ a(x_3^2 - x_1^2) + \frac{2(y_2 - y_1)}{(x_2 - x_1)} -2a(x_2 - x_1) = y_3 - y_1 $

19$ a(x_3^2 - x_1^2) -2a(x_2 - x_1) = y_3 - y_1 - \frac{2(y_2 - y_1)}{(x_2 - x_1)} $

20$ a((x_3^2 - x_1^2) -2(x_2 - x_1)) = y_3 - y_1 - \frac{2(y_2 - y_1)}{(x_2 - x_1)} $

21$ a = \left(y_3 - y_1 - \frac{2(y_2 - y_1)}{(x_2 - x_1)} \right) / \left((x_3^2 - x_1^2) -2(x_2 - x_1)\right) $

2 Answers 2

1

A simpler approach: from $a x_1^2 + b x_1 + c = y_1$ and $a x_2^2 + b x_2 + c = y_2$ you get $a (x_1^2 - x_2^2) + b (x_1 - x_2) = y_1 - y_2$, so (noting that $x_1^2 - x_2^2 = (x_1 - x_2)(x_1 + x_2)$), $b = \dfrac{y_1 - y_2}{x_1 - x_2} - a (x_1 + x_2)$.
Similarly $b = \dfrac{y_1 - y_3}{x_1 - x_3} - a (x_1 + x_3)$. Subtract these: $0 = \dfrac{y_1 - y_2}{x_1 - x_2} - \dfrac{y_1 - y_3}{x_1 - x_3} - a(x_2 - x_3)$ so $a = \dfrac{\dfrac{y_1 - y_2}{x_1 - x_2} - \dfrac{y_1 - y_3}{x_1 - x_3}}{x_2 - x_3}$

  • 0
    Ah yeah. I am now embarrassed. Thanks heaps for the solution.2012-07-10
3

Hint: The calculations are too elaborate. Why do we have $c_1$, $c_2$, and $c_3$? There is one and only one constant term $c$. It can be easily eliminated, resulting in two linear equations involving the unknowns $a$ and $b$.

For the elimination process, solving and substituting works, but is not a good idea. Take the first two equations, subtract. Now $c$ is gone. Take the second equation and the third, subtract. Again, $c$ is gone. We now have two linear equations for $a$ and $b$. Eliminate $b$ by multiplying the first new equation through by $x_2-x_3$, and the second new equation by $x_1-x_2$, so that the coefficients of $b$ match. Subtract, and solve for $a$. Do not expand anything you do not need to.

For a fancier approach that generalizes nicely, look up the Vandermonde Determinant.

Edit: After the comments about the multiple $c_i$, these were removed. The substitution process used is not the optimal approach, but it works. Back substitution is now needed to find the other two coefficients.

  • 0
    I'm not quite up to matrices yet, I'm using this as an exercise to understand basic algebra. So has the error occurred due to the substitution method or one of the steps I've taken? I appreciate the help.2012-07-09