Quadratic Formula, nature of roots with Trigonometric Functions The original problem:

If $0\le a,b\le 3$ and the equation $$x^2+4+3\cos(ax+b)=2x$$ has at least one real solution, then find the value of $a+b$

$$$$
At first, on rearranging, I got the following expression:
$$x^2-2x+(4+3\cos(ax+b))=0$$ I thought this was a quadratic in $x$, and thus from the quadratic formula(and that at least one real root exists), $D\ge 0$ ie $$4-4(4+\cos(ax+b))\ge 0$$ 
$$$$
However I'm not really sure about this. I've treated $\cos(ax+b)$ as a constant term even though the argument of the cosine includes $x$: the variable in which the quadratic expression is.
$$$$Under these circumstances, is it correct to use $3\cos(ax+b)$ as a constant? If not, how could I use the quadratic formula to find values of $x$ satisfying $$x^2-2x+(4+3\cos(ax+b))=0$$
Many thanks in anticipation!
 A: Completing the square,
$$x^2-2x+1=(x-1)^2=-3(1+\cos(ax+b)).$$
The two expressions can only be equal if they are zero, i.e. $x=1$ and $\cos(ax+b)=-1$.
Hence,
$$a+b=\pi.$$
A: since the $3cos(ax+b)$ lies between $[-3,3]$
because $cos x$ has a max and min value as $1,-1$ (respectively)
then $3cos x$ will have $3,-3$
i can write $$-3=<x^2-2x+4<=3$$
i am completing the square !
$$\implies -3=<(x-1)^2+3<=3$$
as you see that the term inside the square has a least value 0 and this equation is always greater than or equal to 3 then $(x-1)$ must be zero !! and $x=1$
and then substituting the value of x we get $cos(a+b)=-1$ $$\implies a+b=\arccos (-1)$$ 
$$a+b=\pi$$and that solved the problem!!
A: Wih a little bit of manipulation we can rewrite your given equation as $$x^2 - 2x + 4 = -3\cos{\left( ax + b \right)}$$
Let $f(x) = x^2 - 2x + 4$. Differentiating to find the minimum, we get 
$$f'(x) = 2x - 2 = 0 \implies x = 1$$
$$f''(x) = 2 > 0 \implies \text{minimum at } x = 1$$
The minimum value of LHS is thus $f(1) = 3$.
The RHS is a cosine whose value oscillates in the range $[-3,3]$. The maximum value of the RHS is thus $3$. So we can see that equality holds if and only if the LHS is minimum and RHS is maximum. We just saw that the LHS, $f(x)$, is minimal only at $x = 1$. Now the value of $x$ is fixed, so the value of the RHS depends only on $a$ and $b$.
Hence, we have that
$$f(1) = 3 = -3\cos(a\times 1 + b) \implies \cos(a+b) = -1$$
I leave it to you to complete the problem from here :)
On a side note: No you can't take $\cos(ax + b)$ as a constant since $x$ is not a constant :)

 $a + b = (2n+1)\pi$ but $0 \le a+b \le 6$. So $n = 0$ and $a + b  = \pi$

