Plotting $f(x) = \sin(x)+\cos(x)$ by converting it to another form

Special Case

It's not that hard. You should just use the summation formula for sines:

$$\sin (x + y) = \sin (x)\cos (y) + \cos (x)\sin (y)$$

This is how it works

$$\eqalign{ \sin (x) + \cos (x) &= \sqrt 2 \left( {{1 \over {\sqrt 2 }}\cos (x) + {1 \over {\sqrt 2 }}\sin (x)} \right) \cr &= \sqrt 2 \left( {\sin ({\pi \over 4})\cos (x) + \cos ({\pi \over 4})\sin (x)} \right) \cr &= \sqrt 2 \sin (x + {\pi \over 4}) \cr} $$

That's all you need to do for this case. If you are interested to tackle down the general case then read the sequel.


General Case

Consider a linear combination of $\sin \alpha x$ and $\cos \alpha x$ as follows

$$y = A \cos \alpha x + B \sin \alpha x$$

where $A$ and $B$ are some real constants. Then we rewrite $y$ in this way

$$y = \sqrt{A^2+B^2} \left( \frac{A}{\sqrt{A^2+B^2}} \cos \alpha x + \frac{B}{\sqrt{A^2+B^2}} \sin \alpha x \right)$$

Now, the magic comes in! We can find a unique angle $\phi$ in the interval $[0,2\pi)$ such that

$$\begin{array}{} \sin \phi = \dfrac{A}{\sqrt{A^2+B^2}} \\ \cos \phi = \dfrac{B}{\sqrt{A^2+B^2}} \end{array}$$

and hence

$$y = \sqrt{A^2+B^2} \left( \sin \phi \cos \alpha x + \cos \phi \sin \alpha x \right) \\$$

Finally, using the summation formula for sines we get

$$y = \sqrt{A^2+B^2} \sin(\alpha x+\phi)$$