If \(x^2 = ax + b\) has solutions \(x = -2\) and \(x = 4\), find the values of \(a\) and \(b\).

We can solve these equations simultaneously: subtracting the first from the second to eliminate \(b\) gives \[12=6a,\] so \(a=2\). Substituting this into the first equation then gives \(b=4+2a=8\).

Finally, we can check our working using the second equation: \(4a+b=4\times2+8=16\), as we required.

Alternatively, we can say \(x^2-ax-b=(x+2)(x-4)\) for all \(x\).

Multiplying out and comparing coefficients gives \(a = 2, b = 8\), as before.