So far we have considered quadratic expressions with no linear
$x$ term. In this video we show how to handle expressions like
$\sqrt{x^2 + 4x - 5}$ or $x^2 + 2x + 5$. The key is to complete the square.

Recall that any quadratic polynomial $x^2 +bx +c$ can be
converted to a perfect square plus a constant term. $$x^2+bx+c=
\left(x + \frac{b}{2}\right)^2+c -
\left(\frac{b}{2}\right)^2=\left(x + \frac{b}{2}\right)^2 +
\left(c-\frac{b^2}{4}\right)$$ This works since when we square
$x+\frac{b}{2}$ we get $x^2+bx+\left(\frac{b}{2}\right)^2$ and we
must subtract the extra term $\left(\frac{b}{2}\right)^2$.

$2-8x-x^2=-(x^2+8x-2)=-\left(\left(x+\frac{8}{2}\right)^2-2-(8/2)^2\right)=-\left(\left(x+\frac{8}{2}\right)^2-2-16\right)=18-(x+4)^2$
Notice: we must have the coefficient of the
quadratic term, $x^2$, equal to one, so we factored out the
minus.

DO: Complete the square for
$x^2+2x+5$ and $5-4x-x^2$. These are computed in the video
so you can check your work when you watch it.

There are two ways to integrate after completing the
square. One is to do a $u$-substitution first, substituting
$u=x+\frac{b}{2}$, and make the stubstitution. After the
$u$-sub we will have an obvious trig substitution integrand.
The second method skips the $u$-sub, and does the trig
substitution on the completed square. The video uses the
second method.

Example of $u$-substitution before doing trig
substitution

In the video above, we completed the square to get
$\displaystyle\int\frac{dx}{x^2+2x+5}=\int\frac{dx}{(x+1)^2+4}$
We want the form $x^2+a^2$, or after the substitution,
$u^2+a^2$. Set $u=(x+1)$. DO:
Do this $u$-sub, and then try to work this through before
looking ahead.

$$\int\frac{dx}{(x+1)^2+4} \overset{\fbox{$
\,\,u\,=\,\,x+1\\du\,=\,\,dx$}}{=}\int\frac{du}{u^2+4}\overset{\fbox{$\,\,
u\,=\,2\tan\theta\\du\,=\,2\sec^2\theta\,d\theta$}}{=}=\int\frac{2\sec^2\theta}{4\tan^2\theta+4}\,d\theta$$
$$=\int\frac{\sec^2\theta}{2\sec^2\theta}\,d\theta=\int\tfrac12
d\theta=\tfrac12\theta+C=\tfrac12\tan^{-1}\left(\frac{x+1}{2}\right)+C$$
We got $\theta$ in terms of $x$ by first writing it in terms of
$u$.
$\theta=\tan^{-1}\left(\frac{u}{2}\right)=\tan^{-1}\left(\frac{x+1}{2}\right).$