The equation \(x^2+ax+b=0\), where \(a\) and \(b\) are different, has solutions \(x=a\) and \(x=b\). How many such equations are there?

As \(x=a\) and \(x=b\) are the solutions to the equation \(x^2+ax+b=0\), we have \[x^2+ax+b\equiv(x-a)(x-b).\]

Expanding gives \[x^2+ax+b\equiv x^2+(-a-b)x+ab\]

Comparing coefficients of these two quadratics, we see that we require \(a=-a-b\) and \(b=ab\).

From the first condition we deduce \(a=-b/2\). Substituting this into the second condition gives \[b=-\frac{b^2}{2},\] which has solutions \(b=0\) and \(b=-2\).

As \(a\) and \(b\) are assumed to be different, we cannot use \(b=0\) because this corresponds to \(a=0\).

For \(b=-2\) we get \(a=1\), which is different from \(b\).

Alternatively, we could have started with the second condition, \(b=ab\). Rearranging this as \(ab-b=0\) and factorising to \(b(a-1)=0\) shows that \(a=1\) or \(b=0\), and we obtain the same solutions (\(a=b=0\) or \(a=1\), \(b=-2\)) again.

As yet a third approach, we could have substituted \(x=a\) and \(x=b\) into the original equation to obtain \(a^2+a^2+b=0\) and \(b^2+ab+b=0\); the first gives \(b=-2a^2\) and the second gives \(b(a+b+1)=0\). From the second equation, we obtain \(b=0\) and hence \(a=0\), or \(b=-a-1\). Substituting the latter into \(b=-2a^2\) gives \(2a^2-a-1=0\) or \((2a+1)(a-1)=0\), so \(a=1\) or \(a=-\frac12\). If \(a=1\), then \(b=-2\), as before. If \(a=-\frac12\), then \(b=-\frac12\), so \(a=b\).

This is strange: we have obtained a third possible solution using this approach, which did not appear in either of the first two approaches. (Though we have to reject it anyway, as \(a=b\), it is still odd that we have found a further solution.)

What’s going on here?

Since the solutions to \(x^2+x-2=0\) are indeed \(x=1\) and \(x=-2\), there is exactly one equation that meets the conditions.