Integration by Completing the Square

Trigonometry

Trigonometry Logo

Integration by Completing the Square

By changing the square, we may rewrite any quadratic polynomial \(a{x^2} + {bx} + c\) in the form

\[a\left( {{u^2} + {k}} \right),\;\;\text{where}\;\;u = x + \frac{b}{{2a}},\;\;k = \frac{{4ac - {b^2}}}{{4{a^2}}}.\]

Completing the square helps when quadratic functions are involved in the integrand.

When the integrand is a rational function with a quadratic expression in the denominator, we can use the following table integrals:

\[\int {\frac{{dx}}{{\sqrt {{x^2} \pm {a^2}} }}} = \ln \left| {x + \sqrt {{x^2} \pm {a^2}} } \right|,\]
\[\int {\frac{{dx}}{{\sqrt {{a^2} - {x^2}} }}} = \arcsin \frac{x}{a},\]
\[\int {\frac{{dx}}{{{a^2} + {x^2}}}} = \frac{1}{a}\arctan \frac{x}{a},\]
\[\int {\frac{{dx}}{{{a^2} - {x^2}}}} = \frac{1}{{2a}}\ln \left| {\frac{{a + x}}{{a - x}}} \right|.\]

Certain other types of integrals involving quadratic functions can be evaluated using trigonometric and hyperbolic substitutions.

Solved Problems

Click or tap a problem to see the solution.

Example 1

Find the integral \[\int {\frac{{dx}}{{{x^2} - 5x + 7}}}.\]

Example 2

Evaluate the integral \[\int {\frac{{dx}}{{{x^2} - x + 2}}}.\]

Example 3

Evaluate the integral \[\int {\frac{{dx}}{{{x^2} + 10x + 26}}}.\]

Example 4

Evaluate the integral \[\int {\frac{{dx}}{{5 - 4x - {x^2}}}}.\]

Example 5

Find the integral \[\int {\frac{{dx}}{{\sqrt {{x^2} + x - 2} }}}.\]

Example 6

Find the integral \[\int {\frac{{dx}}{{8 - 2x - {x^2}}}}.\]

Example 1.

Find the integral \[\int {\frac{{dx}}{{{x^2} - 5x + 7}}}.\]

Solution.

We complete the square in the denominator:

\[{x^2} - 5x + 7 = {x^2} - 2 \cdot \frac{5}{2}x + {\left( {\frac{5}{2}} \right)^2} - {\left( {\frac{5}{2}} \right)^2} + 7 = {\left( {x - \frac{5}{2}} \right)^2} + 7 - \frac{{25}}{4} = {\left( {x - \frac{5}{2}} \right)^2} + \frac{{28 - 25}}{4} = {\left( {x - \frac{5}{2}} \right)^2} + {\left( {\frac{{\sqrt 3 }}{2}} \right)^2}.\]

Make the substitution \(u = x - \frac{5}{2}.\) Then \(du = dx,\) and the integral in \(u-\)terms becomes

\[\int {\frac{{dx}}{{{x^2} - 5x + 7}}} = \int {\frac{{dx}}{{{{\left( {x - \frac{5}{2}} \right)}^2} + {{\left( {\frac{{\sqrt 3 }}{2}} \right)}^2}}}} = \int {\frac{{du}}{{{u^2} + {{\left( {\frac{{\sqrt 3 }}{2}} \right)}^2}}}} .\]

We can easily evaluate the last integral:

\[\int {\frac{{du}}{{{u^2} + {{\left( {\frac{{\sqrt 3 }}{2}} \right)}^2}}}} = \frac{1}{{\frac{{\sqrt 3 }}{2}}}\arctan \frac{u}{{\frac{{\sqrt 3 }}{2}}} + C = \frac{2}{{\sqrt 3 }}\arctan \frac{{x - \frac{5}{2}}}{{\frac{{\sqrt 3 }}{2}}} + C = \frac{2}{{\sqrt 3 }}\arctan \frac{{2x - 5}}{{\sqrt 3 }} + C.\]

Example 2.

Evaluate the integral \[\int {\frac{{dx}}{{{x^2} - x + 2}}}.\]

Solution.

We complete the square in the quadratic expression:

\[{x^2} - x + 2 = {x^2} - 2 \cdot x \cdot \frac{1}{2} + {\left( {\frac{1}{2}} \right)^2} - {\left( {\frac{1}{2}} \right)^2} + 2 = {\left( {x - \frac{1}{2}} \right)^2} - \frac{1}{4} + 2 = {\left( {x - \frac{1}{2}} \right)^2} + \frac{7}{4} = {\left( {x - \frac{1}{2}} \right)^2} + {\left( {\frac{{\sqrt 7 }}{2}} \right)^2}.\]

Making the substitution

\[u = x - \frac{1}{2},\;\;du = dx,\]

we find the integral:

\[\int {\frac{{dx}}{{{x^2} - x + 2}}} = \int {\frac{{dx}}{{{{\left( {x - \frac{1}{2}} \right)}^2} + {{\left( {\frac{{\sqrt 7 }}{2}} \right)}^2}}}} = \int {\frac{{du}}{{{u^2} + {{\left( {\frac{{\sqrt 7 }}{2}} \right)}^2}}}} = \frac{1}{{\frac{{\sqrt 7 }}{2}}}\arctan \frac{u}{{\frac{{\sqrt 7 }}{2}}} + C = \frac{2}{{\sqrt 7 }}\arctan \frac{{x - \frac{1}{2}}}{{\frac{{\sqrt 7 }}{2}}} + C = \frac{2}{{\sqrt 7 }}\arctan \frac{{2x - 1}}{{\sqrt 7 }} + C.\]

Example 3.

Evaluate the integral \[\int {\frac{{dx}}{{{x^2} + 10x + 26}}}.\]

Solution.

We complete the square in the denominator:

\[{x^2} + 10x + 26 = {x^2} + 10x + 25 + 1 = {\left( {x + 5} \right)^2} + 1,\]

so the integral is written as

\[I = \int {\frac{{dx}}{{{x^2} + 10x + 26}}} = \int {\frac{{dx}}{{{{\left( {x + 5} \right)}^2} + 1}}} .\]

Using the substitution

\[u = x + 5,\;\;du = dx,\]

we have

\[I = \int {\frac{{du}}{{{u^2} + 1}}} = \arctan u + C = \arctan \left( {x + 5} \right) + C.\]

Example 4.

Evaluate the integral \[\int {\frac{{dx}}{{5 - 4x - {x^2}}}}.\]

Solution.

First we complete the square in the denominator:

\[5 - 4x - {x^2} = 5 - \left( {{x^2} + 4x} \right) = 9 - \left( {{x^2} + 4x + 4} \right) = 9 - {\left( {x + 2} \right)^2} = {3^2} - {\left( {x + 2} \right)^2}.\]

Then the integral becomes

\[I = \int {\frac{{dx}}{{5 - 4x - {x^2}}}} = \int {\frac{{dx}}{{{3^2} - {{\left( {x + 2} \right)}^2}}}} .\]

Using

\[u = x + 2,\;\;du = dx,\]

we obtain

\[I = \int {\frac{{du}}{{{3^2} - {u^2}}}} = \frac{1}{{2 \cdot 3}}\ln \left| {\frac{{3 + u}}{{3 - u}}} \right| + C = \frac{1}{6}\ln \left| {\frac{{3 + x + 2}}{{3 - \left( {x + 2} \right)}}} \right| + C = \frac{1}{6}\ln \left| {\frac{{5 + x}}{{1 - x}}} \right| + C.\]

Example 5.

Find the integral \[\int {\frac{{dx}}{{\sqrt {{x^2} + x - 2} }}}.\]

Solution.

Complete the square in the denominator:

\[{x^2} + x - 2 = \left( {{x^2} + x + \frac{1}{4}} \right) - \frac{1}{4} - 2 = {\left( {x + \frac{1}{2}} \right)^2} - \frac{9}{4} = {\left( {x + \frac{1}{2}} \right)^2} - {\left( {\frac{3}{2}} \right)^2}.\]

Making the substitution

\[u = x + \frac{1}{2},\;\;du = dx,\]

we obtain

\[\int {\frac{{dx}}{{\sqrt {{x^2} + x - 2} }}} = \int {\frac{{dx}}{{\sqrt {{{\left( {x + \frac{1}{2}} \right)}^2} - {{\left( {\frac{3}{2}} \right)}^2}} }}} = \int {\frac{{du}}{{\sqrt {{u^2} - {{\left( {\frac{3}{2}} \right)}^2}} }}} = \ln \left| {u + \sqrt {{u^2} - {{\left( {\frac{3}{2}} \right)}^2}} } \right| + C = \ln \left| {x + \frac{1}{2} + \sqrt {{x^2} + x - 2} } \right| + C.\]

Example 6.

Find the integral \[\int {\frac{{dx}}{{8 - 2x - {x^2}}}}.\]

Solution.

Completing the square in the denominator yields:

\[8 - 2x - {x^2} = 8 - \left( {{x^2} + 2x} \right) = 9 - \left( {{x^2} + 2x + 1} \right) = {3^2} - {\left( {x + 1} \right)^2}.\]

Hence, the integral can written in the form

\[I = \int {\frac{{dx}}{{8 - 2x - {x^2}}}} = \int {\frac{{dx}}{{{3^2} - {{\left( {x + 1} \right)}^2}}}} .\]

Making the substitution

\[u = x + 1,\;\;du = dx,\]

we have

\[I = \int {\frac{{dx}}{{{3^2} - {{\left( {x + 1} \right)}^2}}}} = \int {\frac{{du}}{{{3^2} - {u^2}}}} = \frac{1}{{2 \cdot 3}}\ln \left| {\frac{{3 + u}}{{3 - u}}} \right| + C = \frac{1}{6}\ln \left| {\frac{{3 + x + 1}}{{3 - \left( {x + 1} \right)}}} \right| + C = \frac{1}{6}\ln \left| {\frac{{4 + x}}{{2 - x}}} \right| + C.\]