Integration By Completing The Square Calculator - Rewrite, Substitute, Integrate
Use this integration by completing the square calculator to evaluate integrals of 1/(ax^2+bx+c) with arctan, logarithm, and rational results and a rewrite.
Integration By Completing The Square Calculator
Results
What Is Integration By Completing The Square Calculator?
An integration by completing the square calculator evaluates the indefinite integral of 1/(ax^2 + bx + c) by rewriting the quadratic denominator, applying a u-substitution, and returning the matching arctan, logarithm, or rational antiderivative. Type the three coefficients a, b, c, and the page reports the completed-square form, the u-substitution, the branch, and the closed-form answer in x plus C.
- • Calculus 2 Homework: Solve textbook problems that ask for the antiderivative of 1/(x^2 + 1), 1/(x^2 + 2x + 2), or 1/(2x^2 + 4x + 4).
- • Definite Integral Setup: Use a closed-form antiderivative of 1/(ax^2 + bx + c) to plug into a definite integral, especially in physics or probability problems.
- • Verifying Partial-Fraction Steps: Cross-check an answer produced by hand or by a partial-fraction-decomposition calculator, especially the arctan branch when the denominator has no real roots.
The same completing-the-square rewrite that turns ax^2 + bx + c into a(x - h)^2 + k also drives this page's integral, and the standalone completing the square calculator applies the same rewrite to vertex-form problems once a u-substitution is added on top.
How Integration By Completing The Square Calculator Works
The page reads the three coefficients a, b, c, completes the square in the denominator, applies the matching u-substitution, and reduces the integral to a standard arctan, logarithm, or simple rational antiderivative.
- a: Leading coefficient. Must be non-zero; if a = 0 the integrand is no longer a proper quadratic.
- b: Linear coefficient. Sets the horizontal shift of the completed square at x = -b/(2a).
- c: Constant term. Together with a and b it sets the discriminant sign.
- D = b^2 - 4ac: Negative D means no real roots and the answer is arctan. Zero D means a perfect square and the answer is a simple rational. Positive D means two real roots and the answer is a logarithm.
For a = 1, b = 0, c = 1 the integral of 1/(x^2 + 1) dx returns arctan(x) + C. For a = 1, b = 2, c = 5 the inner arctan argument becomes (x + 1) / 2, producing 0.5 * arctan((x + 1) / 2) + C, which shows how the scale inside the arctan tracks the completed-square constant. For two-real-root inputs, such as a = 1, b = -3, c = 2, the page returns the logarithm branch with the two roots in the inner fraction, while a = 2, b = -6, c = 4 returns 0.5 * ln |(x - 2) / (x - 1)| + C.
A Worked Example: int 1/(x^2 + 2x + 2) dx
Coefficients a = 1, b = 2, c = 2
1. Complete the square: x^2 + 2x + 2 = (x + 1)^2 + 1. 2. Substitute u = x + 1, so du = dx. 3. The integral becomes int 1/(u^2 + 1) du. 4. Apply the arctan antiderivative: arctan(u) + C. 5. Substitute back: arctan(x + 1) + C.
arctan(x + 1) + C
The page reports the arctan branch, the completed-square form (x + 1)^2 + 1, the u-substitution u = x + 1 with du = dx, and the final antiderivative arctan(x + 1) + C.
According to Wikipedia, completing the square rewrites ax^2 + bx + c as a*(x - h)^2 + k with h = -b/(2a) and k = c - b^2/(4a), and the same rewrite lets you evaluate the integral of 1/(ax^2 + bx + c) using the basic arctan and logarithm integrals.
The discriminant sign that drives the branch selection here is the same discriminant that the quadratic formula calculator uses to count the real roots of ax^2 + bx + c, so the two tools agree on every input that crosses the D = 0 boundary.
Key Concepts Explained
Four ideas make the technique work, and recognizing each one keeps the integral honest when the coefficients get unusual.
Completed-Square Rewrite
The quadratic denominator ax^2 + bx + c is rewritten as a*(x + b/(2a))^2 + (4ac - b^2)/(4a). This is the same rewrite the completing-the-square-calculator already produces for vertex-form problems.
u-Substitution
The substitution u = sqrt(|a|) * (x + b/(2a)) reduces the integrand to a clean 1/(u^2 + k) form, and the matching du = sqrt(|a|) dx absorbs the magnitude of the leading coefficient so the substitution stays real-valued for negative a.
Discriminant Sign
The sign of D = b^2 - 4ac decides which branch the integral takes. Negative D means no real roots and the answer is an arctan. Zero D means a perfect square and the answer is the simple rational -2/(2*a*x + b) + C. Positive D means two real roots and the answer is a logarithm.
Basic Antiderivatives
The arctan branch comes from int 1/(u^2 + 1) du = arctan(u) + C, and the logarithm branch from int 1/(u^2 - a^2) du = (1/(2a)) * ln |(u - a)/(u + a)| + C. Both integrals are listed in every table of integrals.
These four ideas are the only machinery behind the technique, and the page builds each one into a separate line in the result card.
The arctan branch lands on the standard arctan integral, and the companion inverse tangent calculator evaluates arctan(x) at a specific x so you can sanity-check the closed-form coefficient by plugging a sample value.
How to Use This Calculator
Follow four short steps to turn the three coefficients of the quadratic denominator into a closed-form antiderivative.
- 1 Enter the Leading Coefficient a: Type the coefficient in front of x^2. The default 1 matches the standard arctan integral of 1/(x^2 + 1). The value must be non-zero; the page returns a clear error when a = 0.
- 2 Enter the Linear Coefficient b: Type the coefficient in front of x. The default 0 keeps the parabola centered on the y-axis, while a non-zero b shifts the vertex of the completed square.
- 3 Enter the Constant c: Type the constant term. Together with a and b, c sets the discriminant sign.
- 4 Read the Four Result Lines: The result branch line names the family. The completed-square line shows the rewritten denominator. The u-substitution line shows u and du. The antiderivative line shows the final closed form plus C.
For int 1/(2x^2 + 4x + 4) dx, type a = 2, b = 4, c = 4 and the page returns the arctan branch with completed-square form 2 * (x + 1)^2 + 2 and the final antiderivative 0.5 * arctan(x + 1) + C.
When the denominator is a product of quadratics instead of a single trinomial, the partial fraction decomposition calculator produces the per-factor pieces first and the same completing-the-square rewrite then reappears inside each quadratic partial fraction.
Benefits of Using This Calculator
A dedicated integration by completing the square calculator removes the small mistakes that make hand-evaluated integrals of 1/(ax^2 + bx + c) go wrong.
- • Three Result Branches in One Place: The same page returns the arctan (D < 0), logarithm (D > 0), and simple rational (D = 0) branches, so there is no need to switch tools when the discriminant sign changes.
- • Completed-Square and u-Substitution Lines: The page reports the rewrite and the substitution on two separate lines, so the steps that turn a difficult integral into a basic one stay visible.
- • Discriminant Sign Made Explicit: The result branch line states which family the discriminant selected, so it is never ambiguous whether the answer should be an arctan, a logarithm, or a simple rational.
- • Clean Handling of the a = 0 Edge Case: When the leading coefficient is zero the technique does not apply, and the page surfaces a clear error message instead of returning NaN or Infinity.
- • Hand-off to Peer Calculators: The completed-square line lines up with the completing-the-square calculator, the discriminant sign with the quadratic formula calculator, and the arctan branch with the inverse-tangent calculator on the same site.
These benefits matter most in second-semester calculus, where one wrong sign in the discriminant can change the final answer.
When the numerator has higher degree than the quadratic denominator, the polynomial division calculator simplifies the problem to a polynomial plus a proper rational function so the technique on this page can take over.
Factors That Affect Your Results
Three measurable factors control which branch the integral takes, and two practical limits apply to any hand-evaluated or tool-evaluated integral of 1/(ax^2 + bx + c).
Discriminant Sign
The discriminant D = b^2 - 4ac is the single most important number. Negative D forces the arctan branch, zero D collapses the integral to a simple rational, and positive D produces the logarithm branch.
Leading Coefficient Magnitude
The leading coefficient a sets the scale of the u-substitution through sqrt(|a|). When |a| is close to zero, that factor amplifies small input changes in b and c.
Completed-Square Constant
The constant (4ac - b^2)/(4a) is the k in the rewritten denominator a*(x + b/(2a))^2 + k. When k > 0 the integral is an arctan, when k = 0 the integral is a simple rational, and when k < 0 the integral is a logarithm.
- • The closed-form antiderivative is exact only when the denominator is a single quadratic. For products of quadratics or a rational function with a non-trivial numerator, run a partial-fraction-decomposition-calculator pass first; this page will not produce the correct answer alone.
- • Inputs are bounded between -100 and 100 to keep the closed form readable. Values outside that range can overflow the arctan or logarithm formulas, so the page surfaces a clear message.
These factors and limits are the only practical concerns for a single-quadratic denominator. For products of linear or quadratic factors, the partial-fraction-decomposition-calculator handles the next step up.
According to Paul's Online Math Notes, completing the square on a non-monic quadratic like 2x^2 - 3x + 2 turns the integral into the canonical arctan form, with the general antiderivative (2/sqrt(4ac - b^2)) * arctan((2*a*x + b)/sqrt(4ac - b^2)) + C when 4ac - b^2 > 0.
According to Omni Calculator, the same rewrite also drives the integral of 1/(ax^2 + bx + c) dx through the u = sqrt(|a|)*(x + b/(2a)) substitution, reducing the integrand to the standard arctan integral of 1/(1 + u^2).
The two real roots that show up in the logarithm branch of this calculator are the same roots the quadratic equation solver returns for ax^2 + bx + c = 0, so you can read them off the equation solver and paste them into the inner fraction on the result card.
Frequently Asked Questions
Q: What is integration by completing the square?
A: It is a calculus technique for evaluating the indefinite integral of 1/(ax^2 + bx + c). You rewrite the quadratic denominator as a*(x + b/(2a))^2 + (4ac - b^2)/(4a), apply the substitution u = sqrt(|a|) * (x + b/(2a)), and the integral becomes a standard arctan, logarithm, or simple rational integral.
Q: When do you use integration by completing the square instead of partial fractions?
A: Use it when the denominator is a single irreducible quadratic trinomial and the numerator is a constant. For products of linear and quadratic factors, or for non-trivial numerators, a partial-fraction-decomposition-calculator pass is the right first step, and the completing-the-square rewrite then reappears inside each quadratic partial fraction.
Q: How do you complete the square inside an integral?
A: Take ax^2 + bx + c, factor a out of the first two terms, and rewrite a*(x^2 + (b/a)*x) as a*((x + b/(2a))^2 - b^2/(4a^2)). Combine that with the original c to get a*(x + b/(2a))^2 + (4ac - b^2)/(4a). That is the form the page shows in its result card.
Q: What is the role of the discriminant in this technique?
A: The discriminant D = b^2 - 4ac chooses between the three result branches. Negative D selects the arctan branch, zero D collapses the answer to the simple rational -2/(2*a*x + b) + C, and positive D produces the logarithm branch.
Q: How does u-substitution connect to completing the square?
A: Once the denominator is a*(x + b/(2a))^2 + (4ac - b^2)/(4a), the substitution u = sqrt(|a|) * (x + b/(2a)) absorbs the magnitude of the leading coefficient and turns the integral into int 1/(u^2 + k) du. That is the canonical arctan or logarithm integral that the page reduces to in the antiderivative line.
Q: What happens when the quadratic has no real roots?
A: No real roots means 4ac - b^2 > 0, so the integral lands in the arctan branch. The result is (2/sqrt(4ac - b^2)) * arctan((2*a*x + b)/sqrt(4ac - b^2)) + C, which the page reports as the arctan branch with the matching inner argument. You can cross-check the arctan value with the inverse-tangent calculator on the same site.