What is the value of $a^2+b^2$? 
If the range of the function $$f(x)=\frac{x^2+ax+b}{x^2+2x+3}$$ is
  $[-5,4]$ then what is the value of $a^2+b^2$ ?
[$a,b$ are natural numbers]

What will the correct approach to this problem?
I tried using the general method as follows:
$({x^2+2x+3})y={x^2+ax+b}$
or,$x^2(y-1)+x(2y-a)+(b-3y)=0$
Then since $x$ is real the discriminant should be greater than equal to 0.
But this method isn't very efficient and quick for this problem.Any shortcuts possible?


Note that
  $$-5 \leq y \leq 4 \iff (y+5)(y-4) \leq 0 \iff y^2+y-20 \leq 0$$

For $x^2(y-1)+(2y-a)x+(3y-b)=0$ admits real value of $x$,
\begin{align*}
  \Delta & \geq 0 \\
  (2y-a)^2-4(y-1)(3y-b) & \geq 0 \\
  -8y^2+4(3-a+b)y+a^2-4b & \geq 0 \\
  8y^2+4(a-b-3)y-a^2+4b & \leq 0 \\
\end{align*}
Comparing coefficients,
$$8y^2+4(a-b-3)y-a^2+4b \equiv 8(y^2+y-20)$$
$$\implies
\left \{
  \begin{align*}
    a-b-3 &= 2 \\ -a^2+4b &= -160
  \end{align*}
\right.$$
$$\implies (a,b)= (14,9) \: \text{ or } \: (-10,-15)$$
Since $a$ and $b$ are natural numbers, reject $\, (a,b)=(-10,-15)$.
$$\therefore \quad a^2+b^2=277$$
