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

Are there any trigonometric identity that can make $$f(x) = \sin(x)+\cos(x)$$ easier to plot? I have no idea how it becomes a sin graph shape in the end.

• Note that $\sin x+\cos x=\sqrt 2\left(\dfrac 1{\sqrt 2}\sin x+\dfrac 1{\sqrt 2}\cos x\right)=\sqrt 2\sin(x+\pi/4)$ Commented Oct 3, 2015 at 6:18
• How do you get the identity in the bracket? I can't seem to find it anywhere else. Where can I find other examples of such identities? Commented Oct 3, 2015 at 6:40
• Have a look at this. Commented Oct 3, 2015 at 6:42

## 2 Answers

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)$$

Note Using the formula for $$\sin(A)+\sin(B)$$ you get

$$\sin(x)+\cos(x)=\sin(x)+\sin(\frac{\pi}{2}-x)=2\sin( \frac{x+\frac{\pi}{2}-x}{2}) \cos(\frac{x-\frac{\pi}{2}+x}{2})$$ which is easy to calculate and plot.

Note also that $$\cos(x- \frac{\pi}{4})=\cos(\frac{\pi}{4}-x)=\sin( \frac{\pi}{2}-\frac{\pi}{4}+x)$$ which is consistent with the other answer.