124/176
\begin{frame}
  \frametitle{Review - Midterm Exam 3}

  \begin{exampleblock}{}
    Find the area of the region bounded by
    the curves \vspace{-.5ex}
    \begin{talign}
      y = \sin x && y = \cos x &&
      x = 0 && x = \pi/2
    \end{talign}
    \pause
    Area is equal to the area between $\sin x - \cos x$ and the $x$-axis:\vspace{-.5ex}
    \begin{talign}
      A = \int_0^{\pi/2} |\sin x - \cos x|dx
    \end{talign}
    \pause
    We have to find the $x$-intercepts in the interval $[0,\pi/2]$:\vspace{-.5ex}
    \begin{talign}
      \sin x - \cos = 0 \mpause[1]{\;\iff\; \sin x = \cos x} \mpause{\;\iff\; x =} \mpause{ \pi/4}
    \end{talign}
    \pause\pause\pause\pause
    Antiderivative of $f(x) = \sin x - \cos x$ is $F(x) = \pause -\cos x - \sin x$:\vspace{-.5ex}
    \pause
    \only<-15>{
    \begin{talign}
      \alert{A} &= \mpause[1]{
            \left| \int_0^{\pi/4} f(x)dx \right|
            + \left| \int_{\pi/4}^{\pi/2} f(x)dx \right|
          }
      \mpause{ 
        = | F(x) \big]_0^{\pi/4} | + | F(x) \big]_{\pi/4}^{\pi/2} |
      } \\[-.5ex]
      \mpause{ 
        &= | (-\frac{1}{\sqrt{2}} - \frac{1}{\sqrt{2}}) - (-1 - 0)| 
         + | (-0 - 1) - (-\frac{1}{\sqrt{2}} - \frac{1}{\sqrt{2}})|
      }\\
      \mpause{ 
        &= | -\frac{2}{\sqrt{2}} +1| + | -1 + \frac{2}{\sqrt{2}}| 
      }      
      \mpause{ 
        = \sqrt{2} -1 + -1 + \sqrt{2} 
      }      
      \mpause{ 
        \alert{= 2\sqrt{2} -2} 
      }      
    \end{talign}
    }
    \only<16>{
    \begin{center}
    \scalebox{.8}{
    \begin{tikzpicture}[default,xscale=2]
      \def\mfuna{(cos (180/pi *\x))}
      \def\mfunb{(sin (180/pi *\x))}
  
      \diagram[1]{-.5}{3}{-1}{1.2}{1}
      \diagramannotatez
      \def\mfunshift{0}
      \begin{scope}[ultra thick]
        \draw[cred] plot[smooth,domain=-.5:3,samples=100] (\x,{\mfuna}) node[above] {$f(x)$};
        \draw[cblue] plot[smooth,domain=-.5:3,samples=100] (\x,{\mfunb}) node[above,yshift=1.5mm] {$g(x)$};
        \draw[fill=cgreen,draw=none,opacity=.5] plot[smooth,domain=0:pi/4,samples=100] (\x,{\mfuna}) -- plot[smooth,domain=pi/4:0,samples=100] (\x,{\mfunb}) -- cycle;
        \draw[fill=cgreen,draw=none,opacity=.5] plot[smooth,domain=pi/4:pi/2,samples=100] (\x,{\mfuna}) -- plot[smooth,domain=pi/2:pi/4,samples=100] (\x,{\mfunb}) -- cycle;
      \end{scope}
    \end{tikzpicture}
    }
    \end{center}\vspace{-2.5ex}
    \begin{talign}
      \alert{A = 2\sqrt{2} -2}
    \end{talign}
    }
  \end{exampleblock}
\end{frame}