Integration by Completing the Square and Substitution

Enter the coefficients of a quadratic ax² + bx + c and the integration limits to see the completed-square form, the case-specific antiderivative, and the numeric value of ∫ dx/(ax²+bx+c).

Quick Facts

Completing the square
ax² + bx + c = a(x + b/2a)² + (c − b²/4a)
Substituting u = x + b/2a reduces the integral to a standard table form.
Arctangent case (D < 0)
∫dx/(ax²+bx+c) = 1/(a√m) · arctan(u/√m) + C
Applies when the quadratic has no real roots (m > 0).
Logarithmic case (D > 0)
∫dx/(ax²+bx+c) = 1/(2a√(−m)) · ln|(u−√(−m))/(u+√(−m))| + C
Applies when the quadratic has two real roots (m < 0), with m = c/a − b²/4a².

Your Results

Calculated
Completed-square form
-
a(x + h)² + k
Discriminant & case
-
D = b² − 4ac determines the antiderivative type
Antiderivative F(x)
-
General form after substitution u = x + h
Definite integral (p to q)
-
F(q) − F(p)

Ready

Enter a, b, c and the integration limits, then press Calculate.

How Integration by Completing the Square Works

Many rational integrals of the form ∫ dx/(ax² + bx + c) do not match a basic table entry until the quadratic denominator is rewritten as a perfect square plus a remainder. Completing the square turns the messy quadratic into a shifted variable u = x + h, and a simple substitution then reduces the integral to one of three standard forms: an arctangent, a natural logarithm, or a simple rational function, depending on whether the quadratic has real roots.

Formula and method

Start with ax² + bx + c, a ≠ 0. Factor out a and complete the square inside the brackets: ax² + bx + c = a[(x + b/2a)² − b²/4a²] + c = a(x + h)² + k, where h = b/2a and k = c − b²/4a. Substituting u = x + h and m = k/a = c/a − b²/4a² gives ∫dx/(ax²+bx+c) = (1/a)∫du/(u² + m). Note that m = −D/4a², where D = b² − 4ac is the discriminant, so the sign of m always mirrors the sign of −D. If m > 0 (D < 0, no real roots), the antiderivative is (1/a√m)·arctan(u/√m). If m < 0 (D > 0, two real roots), it is a logarithm: (1/2a√(−m))·ln|(u−√(−m))/(u+√(−m))|. If m = 0 (D = 0, a repeated root), the integrand simplifies to 1/(a(x+h)²) and the antiderivative is −1/(a(x+h)).

Common sources of error

  • Sign errors while completing the square: b²/4a² is subtracted, not added, when factoring a out of ax² + bx — double-check the sign of k.
  • Dropping the absolute value in the log case: ln|(u−n)/(u+n)| needs the absolute value bars because u can be on either side of the root.
  • Integrating across a singularity: if the denominator has a real root between the limits of integration (D ≥ 0), the definite integral diverges — check the roots against the interval before trusting a numeric answer.
  • Forgetting the outer factor of a: the 1/a from factoring the quadratic must multiply the entire antiderivative, not just the arctan or ln term.

Checking your result

Differentiate the antiderivative F(x) and confirm it returns the original integrand 1/(ax²+bx+c) — this is the most reliable check. For a definite integral, a quick sanity check is to confirm the sign matches the integrand's sign over the interval (a positive integrand on the whole interval should give a positive result when q > p), and that the magnitude looks reasonable given the interval width.

Applications

  • Integrals of this type appear when finding the response of RLC circuits and damped oscillators, where the transfer function's denominator is a quadratic in the transform variable.
  • Probability and statistics use the same technique to normalize Gaussian-like and Cauchy-like density functions.
  • Control theory and signal processing use partial-fraction and completing-the-square methods to invert Laplace transforms with irreducible quadratic denominators.
  • Physics problems involving inverse-square-type potentials or trajectories under quadratic drag often reduce to this same arctan/log integral family.

Frequently Asked Questions

What does completing the square accomplish in this integral?
Completing the square rewrites ax² + bx + c as a(x + b/2a)² + (c − b²/4a). Substituting u = x + b/2a turns ∫dx/(ax²+bx+c) into the standard form (1/a)∫du/(u²+m), which has a known antiderivative.
How do I know whether the antiderivative is an arctangent or a logarithm?
It depends on the discriminant D = b² − 4ac. If D < 0 the quadratic has no real roots and the antiderivative is (1/a√m)·arctan(u/√m). If D > 0 there are two real roots and the antiderivative is a logarithm, (1/2a√(−m))·ln|(u−√(−m))/(u+√(−m))|. If D = 0 the antiderivative is the rational function −1/(a·u).
What happens if the integration interval contains a root of ax²+bx+c?
The integrand has a vertical asymptote at any real root of the denominator, so the definite integral is undefined (it diverges) whenever the interval of integration contains or ends at that root. This calculator checks for that condition and flags it as an invalid input.
Why can't the leading coefficient a be zero?
If a = 0 the denominator bx + c is linear, not quadratic, so completing the square does not apply. The integral would instead reduce to a simple logarithm, (1/b)ln|bx+c| + C.