Ch. 7.1, Question 10 from “APEX Calculus” by Gregory Hartman.

Find the area of the shaded region in the given graph.

Since the upper curve is the sine curve and the bottom one is cosine, we are going to do upper - lower, thus the integral of sine-cosine.

\[\int_{\pi/4}^{5 \pi/4} sinx-cosx \,dx \ \] \[=-cosx-sinx \]

\[ -cos(5\pi/4)-(-cos(\pi/4))-(sin(5pi/4)-sin(\pi/4))=(-(\frac{-1}{\sqrt{2}})+(\frac{1}{\sqrt{2}})) - (\frac{-1}{\sqrt{2}}+(\frac{1}{\sqrt{2}}) = \]

\[ \frac{1}{\sqrt{2}} + \frac{1}{\sqrt{2}} + \frac{1}{\sqrt{2}} + \frac{1}{\sqrt{2}}= \frac{4}{\sqrt{2}} \] Have to remove the square root from the denominator, so multiply numerator & denominator by the square root:

\[ \frac{4}{\sqrt{2}} * \frac{\sqrt{2}}{\sqrt{2}}=\frac{4\sqrt{2}}{2}=2\sqrt{2}\]

Redoing the problem using R:
top <- function(x){sin(x)}
bottom <- function(x){cos(x)}

# Calculate area over the range [pi/4, 5pi/4]
areaTop <- integrate(top, lower = pi/4, upper = 5*pi/4)

areaBottom <- integrate(bottom, lower = pi/4, upper = 5*pi/4)

# Take the difference of the areas
(areaTop$value - areaBottom$value )
## [1] 2.828427
Checking if they are equal:
2*sqrt(2)==areaTop$value - areaBottom$value 
## [1] TRUE