There are exactly two values for which $x^2=x\sin x+\cos x$ holds

I'm asked to show there is exactly two values for which $x^2=x\sin x+\cos x$

I have no idea where to start but I was thinking about taking the difference $h(x)=x^2-x\sin x-\cos x$ to show that $h'(x) > 0$ if $x>0$ and $h'(x)<0$ if $x<0$ then since $h(0)<0$ there exists exactly two sets of numbers $[a_1,b_1]$ and $[a_2,b_2]$ such that $h(a_1)>0>h(b_1)$ and $h(a_2)<0<h(b_2)$. Therefore by the intermediate value theorem and since $h$ is continuous there exists exactly two numbers $c_1,c_2$ such that $h(c_1)=h(c_2)=0$ implying these numbers hold true in the proposed statement.

Does this hold as a working proof if I refine it a little more? If there is a more proper way I should be doing this please share your thoughts, thank you.

• Yes. Small correction - when you say $h'(x)$ is increasing, you mean $h(x)$ is increasing. – David Dec 15 '15 at 0:37
• Yes thank you corrected. – user3258845 Dec 15 '15 at 0:41
• I don't think you will have any trouble proving both statements true. You might want to take advantage of the fact that $h)(x)=h(-x)$ – WW1 Dec 15 '15 at 1:00
• @DavidG.Stork Why should the statements be false? – egreg Dec 15 '15 at 1:08
• Ooops... I had made a sign error on one term. Comment deleted. – David G. Stork Dec 15 '15 at 1:14

Yes, consider $$f(x)=x^2-x\sin x-\cos x$$ so $$f'(x)=2x-\sin x-x\cos x+\sin x=x(2-\cos x)$$ which is positive for $x>0$ and negative for $x>0$.
Note that the function is even, so it's enough to study it for $x\ge0$. In this interval $f$ is increasing and $f(0)=-1$. On the other hand, $$f\left(\frac{\pi}{2}\right)= \frac{\pi^2}{4}-\frac{\pi}{2}= \frac{\pi}{2}\left(\frac{\pi}{2}-1\right)>0$$ Thus $f$ has a single root in $(0,\infty)$ and another one in $(-\infty,0)$.
First off, the function $h$ is even, so we only need to check that it has precisely one root in the positive $x$-axis.
If you differentiate the function, you get $$\frac{dh}{dx}=x(2-\cos x)$$ which is always positive when $x>0.$ So $h$ is increasing when $x>0.$
Now note that $h(0)=-1<0$ and $h(\pi)=1+\pi ^2>0$ and note that this is the only sign change we can have.
So there is precisely one root (between $0$ and $\pi$) in the positive $x$-axis, so there are two roots on the real line.