I stumbled upon an exercise to integrate a function involving trigonometric identities. So, I reckoned it’d be fun tackling it.
It’s been years since I solved an integration exercise.
I remember having fun trying to find patterns that’d eventually lead me to well-known forms that I could look up in a table and rediscovering properties of different functions and useful identities along the way. I still hold memories of an introductory Quantum Mechanics exam with complicated integrals over strange geometric objects.
The process often involved trigonometric identities and I always had trouble memorising them all, except perhaps for the familiar Pythagorean identity:
\sin^2 x + \cos^2 x = 1
We also have the angle-sum identity for $ \sin $:
\sin (\alpha + \beta) = \sin \alpha \cos \beta + \sin \beta \cos \alpha
Thankfully, they suffice to mechanically derive much of the rest.
The challenge
Weeks ago I took a stab at this simple exercise I found somewhere:
\int_0^{\frac{\pi}{2}} (\sin x + \cos x)^2 \, dx
It looked like a good opportunity to play around and refresh my working memory on integrals and trigonometry in general without taking too much time.
The solution
I started off by expanding $ (\sin x + \cos x)^2 $ into:
\sin^2 x + 2\sin x\cos x + \cos^2 x
I recognised the sum of the first and last terms as equal to $ 1 $ –
per the Pythegorean identity:
1 + 2\sin x \cos x
I remembered that the double-angle identity for $ \sin $ allows us to
simplify $ 2\sin x \cos x $ into:
\sin(2x) = 2\sin x\cos x
Deriving the double-angle identity
By algebraic manipulation and application of the angle sum identity for \( \sin \): \[ \begin{aligned} \sin(2x) & = \sin(x + x) \\ & = \sin x\cos x + \sin x\cos x \\ & = 2\sin x\cos x \qquad \blacksquare \end{aligned} \]Leaving us with the simpler integrand:
1 + \sin(2x)
I plugged it into the integral and omitted the integration limits for brevity:
\int 1 + \sin(2x) \, dx
Integration is a linear operator – roughly, the integral of the sum is the sum of the integrals. Hence, I integrated each term individually by finding the “primitives” (anti-derivatives) of known forms/standard techniques:
x - \frac{1}{2}\cos(2x)
Integration by substitution
By algebraic manipulation and application of the angle sum identity for \( \sin \): \[ \begin{aligned} \int \sin(2x) \, dx & = \int \frac{1}{2}\sin u \, du \qquad (u = 2x) \\ & = \frac{1}{2} \int \sin u \, du \\ & = \frac{1}{2} (-\cos u) \\ & = \frac{-1}{2} \cos(2x) \qquad \blacksquare \end{aligned} \]I reintroduced the limits:
[x - \frac{1}{2}\cos(2x)]^{\frac{\pi}{2}}_0
Finally, after applying them and doing a little manipulation, I got the answer:
\begin{aligned}
(\frac{\pi}{2} - \frac{1}{2}\cos(2 \cdot \frac{\pi}{2})) - (0 - \frac{1}{2}\cos(2 \cdot 0)) \\
& = \frac{\pi}{2} + \frac{1}{2} + \frac{1}{2} \\
& = \frac{\pi}{2} + 1 \qquad \blacksquare
\end{aligned}
Nothing novel or particularly challenging, but it was fun.