\input homework_macros.tex

%\distiller
\printer
\def\dd #1#2{\frac{d#1}{d#2}}

\def\boxit#1{#1}
\newbox\U
\newbox\DU
\newbox\V
\newbox\DV

\def\eeq{\hbox to0pt{\hss$=$\hss}}
\def\partsbox#1#2#3#4{%
\global\setbox\U=\hbox{$#1$}%
\global\setbox\DV=\hbox{$#2$}%
\global\setbox\DU=\hbox{$#3$}%
\global\setbox\V=\hbox{$#4$}%
\setbox0=\hbox{$\matrix{
\hfill u&\eeq&\copy\U\hfill&&\hfill dw&\eeq&\copy\DV\hfill\cr
\hfill du&\eeq&\copy\DU\hfill&&\hfill w&\eeq&\copy\V\hfill\cr}$}
\boxit\box0}

\def\parts{\int\copy\U\copy\DV=\copy\U\copy\V-\int(\copy\V)\copy\DU}

\SN{\jobname}

\pn3.$\int t^2\cos t\>dt$.
\partsbox{t^2}{\cos t\>dt}{2t\>dt}{\sin t}
\quad Hence
$\parts=\copy\U\copy\V-2\int t\sin t\>dt$.
Apply ``Parts'' to
$\int t\sin t\>dt$ with
\partsbox{t}{\sin t\> dt}{dt}{-\cos t}
so $\int\copy\U\copy\DV=\copy\U(\copy\V)-\int(\copy\V)\copy\DU=
-t\cos t+\int\cos t\>dt=-t\cos t+\sin t+C$.
Putting these two results together, we get
$\int t^2\cos t\>dt=t^2(\sin t)-2\br2{-t\cos t+\sin t}+C=
t^2(\sin t)+2t\cos t-2\sin t +C$.

\pn5.$\int_1^2x\ln x\>dx$.
Try $u=x$, $dw=\ln x\>dx$.
To do this, we need $\int dw=\int\ln x\>dx$ and this can be done by
parts or gotten from the book:
$\int\ln x\>dx=x\ln x - x+C$, so $w=x\ln x - x$ and $du=dx$.
Then $\int_1^2x\ln x\>dx=x(x\ln x - x)\Big\vert^2_1-
\int^2_1 (x\ln x - x)dx=
\br1{2(2\ln2-2)}-\br1{1(1\ln1-1)} +\int^2_1 x\>dx-\int_1^2x\ln x\>dx=
4\ln2-4-1(1\cdot0-1) +\frac{x^2}{2}\Big\vert^2_1-\int_1^2x\ln x\>dx=
4\ln2-4+1 +\frac{2^2}{2}-\frac{1}{2}-\int_1^2x\ln x\>dx=
4\ln2-3+2-\frac12-\int_1^2x\ln x\>dx=
4\ln2-1-\frac12-\int_1^2x\ln x\>dx=
4\ln2-\frac32-\int_1^2x\ln x\>dx$.
Solve for $\int^2_1 x\ln x\>dx$:
$2\int^2_1 x\ln x\>dx=4\ln2-\frac32$ so
$\int^2_1 x\ln x\>dx=2\ln2-\frac34=\ln4-\frac34$.

\pn7.$\int\arctan y\>dy$.
\partsbox{\arctan y}{dy}{\frac{dy}{1+y^2}}{y} so
$\int\arctan y\>dy=y\arctan y-\int\frac{y}{1+y^2}\>dy$.
This last integral can be done by substitution $u=y^2+1$, $du=2y\>dy$,
so $\int\frac{y}{1+y^2}\>dy=
\frac 12\int\frac{du}{u}=\frac12\ln\vert u\vert+C=
\frac12\ln(1+y^2)+C$ so
$\int\arctan y\>dy=y\arctan y-\frac12\ln(1+y^2)+C$.

\pn13.$\int(x^2-5x)e^x dx=
\int x^2e^x dx-5\int xe^xdx$.
Do $\int x^2e^xdx$ by parts
\partsbox{x^2}{e^xdx}{\hbox to10pt{$2x\>dx$\hss}}{\hbox to10pt{$e^x$\hss}}:\hfill\par
so
$\int x^2e^xdx=x^2e^x-2\int xe^xdx$.
Do $\int xe^xdx$ by parts:
\partsbox{x}{e^xdx}{dx}{e^x} so
$\int xe^xdx=xe^x-\int e^xdx=xe^x-e^x+C$.
Hence $\int x^2e^xdx=x^2e^x-2\br1{xe^x-e^x}+C=
x^2e^x-2xe^x+2e^x+C$.
Finally 
$\int(x^2-5x)e^x dx=(x^2e^x-2xe^x+2e^x)-5(xe^x-e^x)+C=
x^2e^x-7xe^x+7e^x+C=(x^2-7x+7)e^x+C$.

\pn21.$\int e^\theta\sin\theta\>d\theta$.
\partsbox{e^\theta}{\sin\theta\>d\theta}{e^\theta d\theta}{-\cos\theta}
\quad so $\int e^\theta\sin\theta\>d\theta=
-e^\theta\cos\theta-\br1{\int(-\cos\theta)e^\theta d\theta}=
-e^\theta\cos\theta+\int e^\theta\cos\theta\>d\theta$.
We try $\int e^\theta\cos\theta\>d\theta$ by parts also:
\partsbox{e^\theta}{\cos\theta\>d\theta}{e^\theta d\theta}{\sin\theta}
\quad so
$\int e^\theta\cos\theta\>d\theta=
e^\theta\sin\theta-\int e^\theta\sin\theta\>d\theta$.
Hence
$\int e^\theta\sin\theta\>d\theta=-e^\theta\cos\theta+\br1{
e^\theta\sin\theta-\int e^\theta\sin\theta\>d\theta}$.
Solving for $\int e^\theta\sin\theta\>d\theta$ yields
$2\int e^\theta\sin\theta\>d\theta=
-e^\theta\cos\theta+e^\theta\sin\theta$, so
$\int e^\theta\sin\theta\>d\theta=
\frac{(\sin\theta - \cos\theta)}2e^\theta+C$.


\pn27.$\int^{\pi/3}_0 x\tan^2x\>dx$. Parts would be nice but with $u=x$
we will need $\int\tan^2x\>dx$.
We know $\int\sec^2x\>dx$ and $\tan^2=\sec^2-1$ so
$\int\tan^2x\>dx=\int\sec^2x\>dx-\int\>dx=
\tan x-x+C$.
Now by parts,
\partsbox{x}{\tan^2x\>dx}{dx}{\tan x-x}\quad so
$\int^{\pi/3}_0 x\tan^2x\>dx=
x(\tan x - x)\Big\vert^{\pi/3}_0-\int (\tan x - x)\>dx=
\br2{\frac{\pi}3\br1{\tan(\pi/3)-\pi/3}}-
\br2{0\br1{\tan(0)-0}}-\br1{\ln\vert\sec x\vert \Big\vert^{\pi/3}_0-
\frac{x^2}{2}\Big\vert^{\pi/3}_0}=
\frac{\pi}3(\sqrt 3-\frac{\pi}3)-
\br1{\ln\vert\sec(\pi/3)\vert-\frac{(\pi/3)^2}2-\ln\vert\sec(0)\vert-0}=
\frac{\pi\sqrt3}{3}-\frac{\pi^2}{9}-(\ln2-\ln1)=
\frac{\pi\sqrt3}{3}-\frac{\pi^2}{9}+\frac{\pi^2}{18}-\ln2=
\frac{\pi\sqrt3}{3}-\frac{\pi^2}{18}-\ln2$.
Another way to proceed is to make the substitution $z=\tan x$, $dz=\sec^2 x\>dx=
(1+z^2)\>dx$ so $dx=\frac{dz}{1+z^2}$.
Hence
$\int^{\pi/3}_0 x\tan^2x\>dx=\int^{\sqrt3}_{0}(\arctan z)\frac{z^2}{1+z^2}\>dz$.
Now \partsbox{\arctan z}{\frac{z^2dz}{1+z^2}}{\frac{dz}{1+z^2}}{?}.
To find $w$ integrate $\int\frac{z^2}{1+z^2}dz=
\int 1dz-\int\frac{dz}{1+z^2}=z-\arctan z+C$ so take
$w=z-\arctan z$.
Then 
$\int^{\sqrt3}_{0}(\arctan z)\frac{z^2}{1+z^2}\>dz=
(\arctan z)(z-\arctan z)\Big\vert^{\sqrt3}_0-
\int^{\sqrt3}_0(z-\arctan z)\frac{dz}{1+z^2}=
\frac{\pi}{3}(\sqrt3-\frac{\pi}{3})-0-
\int^{\sqrt3}_0\frac{z dz}{1+z^2}+\int^{\sqrt3}_0\frac{\arctan z\>dz}{1+z^2}$.
Now
$\int^{\sqrt3}_0\frac{z dz}{1+z^2}=\frac12\ln(1+z^2)\Big\vert^{\sqrt3}_0=
\frac12\ln 4=\ln2$ and
$\int^{\sqrt3}_0\frac{\arctan z\>dz}{1+z^2}$ can be integrated by the substitution
$w=\arctan z$, $dw=\frac{dz}{1+z^2}$ so
$\int^{\sqrt3}_0\frac{\arctan z\>dz}{1+z^2}=\int^{\pi/3}_0 w\>dw=\frac{w^2}{2}
\Big\vert^{\pi/3}_0=\frac{\pi^2}{18}$.
The pieces fit together as above.


\pn29.$\int\sin(\ln x)dx$.
One way is by parts: \partsbox{\sin(\ln x)}{dx}{\frac{\cos(\ln x)\>dx}{x}}{x}
\quad so
$\int\sin(\ln x)dx=x\sin(\ln x)-\int x\frac{\cos(\ln x)\>dx}{x}=
x\sin(\ln x)-\int \cos(\ln x)\>dx$.
Repeat the procedure for
$\int \cos(\ln x)\>dx$: 
\partsbox{\cos(\ln x)}{dx}{\frac{-\sin(\ln x)\>dx}{x}}{x}\quad so
$\int \cos(\ln x)\>dx=x\cos(\ln x)-\int x\frac{-\sin(\ln x)\>dx}{x}=
x\cos(\ln x)+\int \sin(\ln x)\>dx$.
Hence 
$\int\sin(\ln x)dx=x\sin(\ln x)-\br1{x\cos(\ln x)+\int\sin(\ln x)\>dx}=
x\sin(\ln x)-x\cos(\ln x)-\int\sin(\ln x)\>dx$ and we can solve for
$\int\sin(\ln x)dx$:
$2\int\sin(\ln x)dx=x\sin(\ln x)-x\cos(\ln x)$ so
$\int\sin(\ln x)dx=\frac{x(\sin(\ln x)-\cos(\ln x))}2+C$.
A second approach.
Substitute $u=\ln x$, $du=\frac{dx}x$, so $dx=xdu=e^u du$.
Hence $\int\sin(\ln x)dx=\int e^u\sin u du$ and we have seen
how to integrate this integral using parts twice.

\pn47.The two formulae are both correct since
$\sin(\arccos x)=\sqrt{1-x^2}$.


\end