Integration by Completing the Square Calculator
Solve integrals of rational functions and radical quadratics by completing the square and u-substitution with detailed step-by-step solutions and definite integral bounds.
Integrating by Completing the Square and Substitution
In calculus, integrating rational functions or radical expressions containing a quadratic denominator ($ax^2 + bx + c$) often cannot be done using basic power rules alone. When the quadratic denominator does not factor neatly into simple linear terms or when it is inside a square root, completing the square transforms the quadratic expression into vertex form:
$$ax^2 + bx + c = a\left(x + \frac{b}{2a}\right)^2 + \left(c - \frac{b^2}{4a}\right)$$
By substituting $u = x + \frac{b}{2a}$ (where $du = dx$), the integral reduces directly into well-known standard forms involving inverse trigonometric functions like $\arctan(u)$, natural logarithms $\ln|u|$, or inverse hyperbolic functions.
Step-by-Step Integration Method
Step 1: Complete the Square on the Quadratic Expression
Given the quadratic polynomial $ax^2 + bx + c$:
- Factor out $a$ from the first two terms: $a\left(x^2 + \frac{b}{a}x\right) + c$.
- Add and subtract $\left(\frac{b}{2a}\right)^2 = \frac{b^2}{4a^2}$ inside the parentheses.
- Express as a perfect square plus a remainder: $a(x - h)^2 + k$, where $h = -\frac{b}{2a}$ and $k = c - \frac{b^2}{4a}$.
You can also use our standalone Completing the Square Calculator to practice the algebraic reduction independently.
Step 2: Split the Linear Numerator ($px + q$)
If the numerator contains an $x$-term ($p \neq 0$), decompose $px + q$ into a multiple of the denominator's derivative $(2ax + b)$ and an auxiliary constant:
$$px + q = \frac{p}{2a}(2ax + b) + \left(q - \frac{pb}{2a}\right)$$
The first part integrates by standard logarithmic substitution $\int \frac{f'(x)}{f(x)} dx = \ln|f(x)|$, while the second constant part is integrated using the completed square form.
Step 3: Apply the Standard Integration Formulas
Depending on the discriminant $\Delta = b^2 - 4ac$ and whether the denominator is rational or under a radical:
- Rational form with positive remainder ($k/a = M^2 > 0$): $$\int \frac{1}{u^2 + M^2} du = \frac{1}{M} \arctan\left(\frac{u}{M}\right) + C$$
- Rational form with negative remainder ($k/a = -M^2 < 0$): $$\int \frac{1}{u^2 - M^2} du = \frac{1}{2M} \ln\left|\frac{u - M}{u + M}\right| + C$$
- Radical form with $a > 0$: $$\int \frac{1}{\sqrt{u^2 + M^2}} du = \operatorname{arsinh}\left(\frac{u}{M}\right) + C = \ln\left|u + \sqrt{u^2 + M^2}\right| + C$$
- Radical form with $a < 0$: $$\int \frac{1}{\sqrt{M^2 - u^2}} du = \arcsin\left(\frac{u}{M}\right) + C$$
Worked Example
Evaluate the indefinite integral $\int \frac{1}{x^2 + 4x + 13} dx$:
- Identify $a = 1, b = 4, c = 13$.
- Complete the square: $x^2 + 4x + 13 = (x + 2)^2 - 4 + 13 = (x + 2)^2 + 9 = (x + 2)^2 + 3^2$.
- Set $u = x + 2$, with $du = dx$ and $M = 3$.
- Integrate: $\int \frac{1}{u^2 + 3^2} du = \frac{1}{3} \arctan\left(\frac{u}{3}\right) + C$.
- Substitute back $u$: $\frac{1}{3} \arctan\left(\frac{x + 2}{3}\right) + C$.
Explore related inverse trigonometric evaluations with our Arctan Calculator and Arcsin Calculator.
Frequently Asked Questions
When should I use completing the square for integration instead of partial fractions?
Use completing the square when the quadratic denominator cannot be factored over the real numbers (when the discriminant is negative, Delta < 0) or when the quadratic appears under a square root radical. If the denominator factors into distinct real linear terms, partial fractions or logarithmic forms are typically easier.
Why does completing the square lead to arctan functions?
The standard derivative of arctan(x) is 1 / (1 + x^2). When a quadratic polynomial with a negative discriminant is converted into the form a((x - h)^2 + M^2), the integral directly matches the 1 / (u^2 + M^2) pattern that integrates to (1/M) arctan(u/M).
How do you handle a non-zero linear coefficient p in the numerator (px + q)?
Decompose the numerator by expressing px + q as a multiple of the denominator derivative (2ax + b) plus a constant remainder. This splits the integral into two simpler integrals: one that evaluates to a natural logarithm and one that evaluates via completing the square.
Can this method solve definite integrals with specific limits?
Yes. Once the antiderivative F(x) is obtained, apply the Fundamental Theorem of Calculus by computing F(upper_bound) - F(lower_bound), provided the integrand is continuous across the integration interval.