Can't solve quadratic function
I'm trying to get a simple quadratic function of the form $y=ax^2+bx+c$ which goes through the following points:
$$(0;0) \;(\frac d2;2)\; (d;0)$$
The solution I've calculated $3$ times on paper has always been $y=\frac8d- \frac{8x^2}{d^2}$, but this can't be true, for an arbitrary $d$, putting $x$ as $0$ should result in $0$, but $\frac8{10}-8\times{\frac0{100}}$ is $\frac 8{10}$, and not $0$.
Neither does input $d$ result in $0 \to y=\frac 8d$
Am I just approaching this problem incorrectly or am I daft?
Solution 1:
The key bit to notice is that you've been given the roots of such a quadratic. Namely the roots are ${x=0}$ and ${x=d}$. This must mean your quadratic can be written of the form
$${y=Ax(x-d)}$$
(since any polynomial can be factorised over it's roots) where ${A}$ is a constant to be determined.
If we plug in ${x=\frac{d}{2}}$, want the result to be ${2}$. As an equation, that is
$${A\frac{d}{2}\left(\frac{d}{2}-d\right)=2}$$
We can then rearrange for ${A}$ to get
$${A=\frac{2}{\frac{d}{2}\left(\frac{d}{2}-d\right)}=\frac{-8}{d^2}}$$
Hence
$${y=\frac{-8}{d^2}x(x-d)=-\frac{8}{d^2}x^2 + \frac{8}{d}}$$
Solution 2:
Lagrange's interpolation formula instantly yields $$y(x)=2\,\frac{x(x-d)}{\frac d2\bigl(\frac d2-d\bigr)}.$$