I have a quadratic equation that I have attempted to manipulate algebraically but still don't have a reasonable solution.
Given a quadratic equation as follows
$a(x-k)^2 + b(k-c)^2$
how could this be expressed in the form
$d(e-k)^2 + f$ such that the terms $d$, $e$ and $f$ do not involve $k$, preferably using completing the square approach.
Given $ a(x-k)^2 + b(k-c)^2 = d(e-k)^2+f$, you're right, the easiest way is to complete the square.
First, we need to expand the expression:
$$ a(x - k)^2 + b(k - c)^2 = ax^2 - 2axk + ak^2 + bk^2 - 2bck + bc^2 $$
Then, we group within different powers of $k$:
$$ = ak^2 + bk^2 - 2axk - 2bck + ax^2 + bc^2 $$ $$ = (a+b)k^2 - 2(ax + bc)k + ax^2 + bc^2 $$
Next, we factor out $(a+b)$ from the first two terms and complete the square using just those two terms:
$$ = (a+b)\left[k^2 - 2\left(\frac{ax + bc}{a+b}\right)k\right] + ax^2 + bc^2 $$
$$ = (a+b)\left[k^2 - 2\left(\frac{ax + bc}{a+b}\right)k + \left(\frac{ax + bc}{a+b}\right)^2 \right] + ax^2 + bc^2 - \frac{(ax + bc)^2}{a+b} $$
$$ = (a+b)\left(k - \frac{ax + bc}{a+b}\right)^2 + ax^2 + bc^2 - \frac{(ax + bc)^2}{a+b} $$
At this point, we can reverse the order of the expression within the square (to look more like the expression we're trying to replicate):
$$ = (a+b)\left(\frac{ax + bc}{a+b} - k\right)^2 + ax^2 + bc^2 - \frac{(ax + bc)^2}{a+b} $$
With a bit more manipulation, we can further simplify the expression after the square:
$$ = (a+b)\left(\frac{ax + bc}{a+b} - k\right)^2 + \frac{(a+b)(ax^2 + bc^2) - (ax + bc)^2}{a+b} $$
$$ = (a+b)\left(\frac{ax + bc}{a+b} - k\right)^2 + \frac{a^2x^2 + abx^2 + abc^2 + b^2c^2 - a^2x^2 - 2abcx + b^2c^2}{a+b} $$
$$ = (a+b)\left(\frac{ax + bc}{a+b} - k\right)^2 + \frac{abx^2 + abc^2 - 2abcx}{a+b} $$
$$ = (a+b)\left(\frac{ax + bc}{a+b} - k\right)^2 + \frac{ab}{a+b}(x^2 - 2abcx + c^2) $$
$$ = (a+b)\left(\frac{ax + bc}{a+b} - k\right)^2 + \frac{ab}{a+b}(x - c)^2 $$
Comparing against the form we want: $d(e-k)^2+f$, we have:
$$ d = a + b , $$ $$ e = \frac{ax + bc}{a+b} , $$ $$ f = \frac{ab}{a+b}(x - c)^2 . $$