A puzzling step in a solution for "Find $\sin(x)$ and $\cos(x)$, if $a\sin(x)+b\cos(x)=c$" A textbook problem:

Find $\sin(x)$ and $\cos(x)$, if $a\sin(x)+b\cos(x)=c$

The solution from the textbook:

Let's divide each term of this equation by $\sqrt{a^2+b^2}$:
  $$\frac{a}{\sqrt{a^2+b^2}}\sin(x)+\frac{b}{\sqrt{a^2+b^2}}\cos(x)=\frac{c}{\sqrt{a^2+b^2}}$$
  Since the sum of squares of $\frac{a}{\sqrt{a^2+b^2}}$ and $\frac{b}{\sqrt{a^2+b^2}}$ equals 1, then there will always exist an angle, let's call it $\phi$, for which 
  $$\sin(\phi)=\frac{a}{\sqrt{a^2+b^2}};$$
  $$\cos(\phi)=\frac{b}{\sqrt{a^2+b^2}}$$
  Using this, let's transform our equation to
  $$\sin(\phi)sin(x)+cos(\phi)cos(x)=\frac{c}{\sqrt{a^2+b^2}}$$
  This will bring us to
  $$\cos(x-\phi)=\frac{c}{\sqrt{a^2+b^2}}$$ 

This I understand. But the next step is:

It is evident from this that 
  $$\sin(x-\phi)=\pm\frac{\sqrt{a^2+b^2-c^2}}{\sqrt{a^2+b^2}}$$

Could you give me a hint regarding this last transformation? 
 A: $$\sin^2(x-\phi)+\cos^2(x-\phi)=1$$
$$\sin(x-\phi)=\pm\sqrt{1-\cos^2(x-\phi)}$$ 
But $\cos(x-\phi)=\frac{c}{\sqrt{a^2+b^2}}$
Therefore $\sin(x-\phi)=\pm\sqrt{1-\cos^2(x-\phi)}=\pm\sqrt{1-(\frac{c}{\sqrt{a^2+b^2}})^2}=\pm\sqrt{1-\frac{c^2}{a^2+b^2}}$
This gives: $\pm\sqrt{\frac{a^2+b^2}{a^2+b^2}-\frac{c^2}{a^2+b^2}}=\pm\sqrt{\frac{a^2+b^2-c^2}{a^2+b^2}}$
I believe this is explanatory enough
A: Using Anurag A's hint, 
$$\sin(x-\phi)=\pm\sqrt{1-\cos^2(x-\phi)}$$ 
Since 
$$\left(\frac{a}{\sqrt{a^2+b^2}}\right)^2+\left(\frac{b}{\sqrt{a^2+b^2}}\right)^2=1,$$
$$\sin(x-\phi)=\pm\sqrt{\left(\frac{a}{\sqrt{a^2+b^2}}\right)^2+\left(\frac{b}{\sqrt{a^2+b^2}}\right)^2-\left(\frac{c}{\sqrt{a^2+b^2}}\right)^2};$$ 
$$\sin(x-\phi)=\pm\frac{\sqrt{a^2+b^2-c^2}}{\sqrt{\left(\sqrt{a^2+b^2}\right)^2}}=\pm\frac{\sqrt{a^2+b^2-c^2}}{\sqrt{a^2+b^2}}$$
A: Let's say you posted like this:
~~~~~
for which 
$$\cos(\phi)=\frac{a}{\sqrt{a^2+b^2}};$$
$$\sin(\phi)=\frac{b}{\sqrt{a^2+b^2}}$$
Using this, let's transform our equation to
$$\cos(\phi)\sin(x)+\sin(\phi)\cos(x)=\frac{c}{\sqrt{a^2+b^2}}$$
This will bring us to
$$ \sin(x+\phi)=\frac{c}{\sqrt{a^2+b^2}}$$ 
This I understand. But the next step is:

It is evident from this that

$$\cos(x+\phi)=\pm\frac{\sqrt{a^2+b^2-c^2}}{\sqrt{a^2+b^2}}$$
Could you give me a hint regarding this last transformation? 
~~~~
You can see not immediately catching the $\sin, \cos $ Pythagorean relationship.
