Integration by Completing the Square Calculator

Convert integrals of the form 1/(ax2+bx+c) to arctan or logarithmic form using completing the square.

Enter Quadratic Coefficients

Integral of dx / (ax2 + bx + c)

Result

Antiderivative
arctan((x+2)/1) + C
Integral TypeArctan form
Discriminant-4
Completed Square(x+2)^2 + 1

Step-by-Step Solution

integral dx/(x^2+4x+5) = arctan((x+2)/1) + C

Integration by Completing the Square

Completing the square is a powerful technique for evaluating integrals involving quadratic expressions in the denominator. By rewriting the quadratic ax2 + bx + c in the form a(x + h)2 + k, we can match the integral to standard forms involving arctan or natural logarithm.

This technique is especially useful when the quadratic cannot be factored over the reals (negative discriminant), leading to an arctangent result. When the discriminant is positive, partial fractions produce a logarithmic result.

The Method

Step 1: Factor out a

Write ax2+bx+c as a(x2+(b/a)x) + c.

a[x^2 + (b/a)x] + c

Step 2: Complete the Square

Add and subtract (b/(2a))2 inside the bracket.

a[(x + b/2a)^2 - (b/2a)^2] + c

Step 3: Simplify

Combine constants: a(x+h)2 + k where k = c - b2/(4a).

a(x + h)^2 + k

Step 4: Integrate

If k/a > 0: arctan form. If k/a < 0: partial fractions / ln form.

(1/sqrt(k)) arctan((x+h)/sqrt(k/a))

Standard Integration Results

Arctan Form (Discriminant < 0)

When b2 - 4ac < 0, the quadratic has no real roots and the integral produces an arctangent:

integral dx/(x2 + k2) = (1/k) arctan(x/k) + C

Logarithmic Form (Discriminant > 0)

When b2 - 4ac > 0, the quadratic factors into two linear terms and partial fractions give logarithms:

integral dx/((x-r1)(x-r2)) = (1/(r1-r2)) ln|(x-r1)/(x-r2)| + C

When to Use This Technique

  • Integrals of the form 1/(ax2+bx+c) where b is not 0 (otherwise, direct arctan or partial fractions apply).
  • When the quadratic in the denominator cannot be easily factored.
  • As a preparation step before applying trigonometric substitution.
  • For integrals with x in the numerator, split into derivative-of-denominator plus constant parts.

Tips for Success

  • Always factor out the leading coefficient a before completing the square.
  • Check the discriminant first: b2-4ac determines arctan vs. ln form.
  • Don't forget the constant of integration (+C).
  • Verify your answer by differentiating the result.