Polynomial Long Division Calculator
Use this calculator to perform polynomial long division step-by-step. Enter your dividend and divisor polynomials in the format ax^n + bx^(n-1) + ... + c. For example, 3x^2 - 2x + 1 or x^3 + 5.
Understanding Polynomial Long Division
Polynomial long division is an algorithm for dividing a polynomial by another polynomial of the same or lower degree. It's similar to the numerical long division you learned in elementary school, but applied to algebraic expressions.
When is it Used?
- Factoring Polynomials: If you know a root of a polynomial, you can use long division to find a factor, which helps in finding other roots.
- Simplifying Rational Expressions: Dividing polynomials can simplify complex fractions involving polynomials.
- Finding Asymptotes: In calculus, it's used to find slant (oblique) asymptotes of rational functions.
- Solving Equations: It can help reduce the degree of a polynomial equation, making it easier to solve.
The Process Explained (Step-by-Step)
Let's consider dividing a dividend polynomial P(x) by a divisor polynomial D(x).
- Arrange Polynomials: Write both the dividend and the divisor in descending powers of the variable. If any powers are missing, include them with a coefficient of zero (e.g.,
x^3 + 0x^2 + 0x + 5). - Divide Leading Terms: Divide the leading term of the dividend by the leading term of the divisor. This gives you the first term of the quotient.
- Multiply: Multiply this quotient term by the entire divisor polynomial.
- Subtract: Subtract the result from the dividend. Be careful with signs! This gives you a new remainder.
- Bring Down (or Repeat): If there are more terms in the original dividend, "bring down" the next term to form a new dividend. In polynomial division, you essentially just use the new remainder as your next dividend.
- Repeat: Continue steps 2-5 until the degree of the remainder is less than the degree of the divisor.
The final result is expressed as: P(x) / D(x) = Q(x) + R(x) / D(x), where Q(x) is the quotient and R(x) is the remainder.
Example Calculation:
Let's divide x^3 - 2x^2 - 4 by x - 3.
Step 1: Divide x^3 (leading term of dividend) by x (leading term of divisor) = x^2. This is the first term of our quotient.
Step 2: Multiply x^2 by the divisor (x - 3) = x^3 - 3x^2.
Step 3: Subtract (x^3 - 3x^2) from the dividend (x^3 - 2x^2 - 4):
x^3 - 2x^2 + 0x - 4
- (x^3 - 3x^2 + 0x + 0)
--------------------
x^2 + 0x - 4
The new remainder is x^2 - 4.
Step 4: Repeat with the new remainder x^2 - 4 as the dividend. Divide x^2 by x = x. Add x to the quotient.
Step 5: Multiply x by (x - 3) = x^2 - 3x.
Step 6: Subtract (x^2 - 3x) from (x^2 - 4):
x^2 + 0x - 4
- (x^2 - 3x + 0)
--------------------
3x - 4
The new remainder is 3x - 4.
Step 7: Repeat. Divide 3x by x = 3. Add 3 to the quotient.
Step 8: Multiply 3 by (x - 3) = 3x - 9.
Step 9: Subtract (3x - 9) from (3x - 4):
3x - 4
- (3x - 9)
--------------------
5
The final remainder is 5. Its degree (0) is less than the divisor's degree (1), so we stop.
Result:
Quotient (Q(x)): x^2 + x + 3
Remainder (R(x)): 5
So, (x^3 - 2x^2 - 4) / (x - 3) = x^2 + x + 3 + 5 / (x - 3).
3x^2 - 2x + 1";
return;
}
if (divisorCoeffs.length === 1 && divisorCoeffs[0] === 0) {
resultDiv.innerHTML = "Error: Divisor cannot be zero.";
return;
}
if (dividendCoeffs.length === 1 && dividendCoeffs[0] === 0) {
resultDiv.innerHTML = "Quotient: 0Remainder: 0";
return;
}
if (divisorCoeffs.length – 1 > dividendCoeffs.length – 1) {
resultDiv.innerHTML = "Quotient: 0Remainder: " + formatPolynomial(dividendCoeffs) + "";
return;
}
var currentRemainder = […dividendCoeffs];
var divisorDegree = divisorCoeffs.length – 1;
var quotientCoeffs = [0]; // Initialize with a zero polynomial
var stepsHtml = "Step-by-Step Division:
"; var stepNum = 1; while (currentRemainder.length – 1 >= divisorDegree && currentRemainder[0] !== 0) { var currentRemainderDegree = currentRemainder.length – 1; var leadingRemainderCoeff = currentRemainder[0]; var leadingDivisorCoeff = divisorCoeffs[0]; var quotientTermCoeff = leadingRemainderCoeff / leadingDivisorCoeff; var quotientTermDegree = currentRemainderDegree – divisorDegree; // Add this term to the quotient var currentQuotientMaxDegree = quotientCoeffs.length – 1; var targetMaxDegree = Math.max(currentQuotientMaxDegree, quotientTermDegree); var tempQuotientCoeffs = new Array(targetMaxDegree + 1).fill(0); // Copy existing quotient terms, aligning them to the new max degree for (var i = 0; i < quotientCoeffs.length; i++) { var oldDegree = currentQuotientMaxDegree – i; var newIndex = targetMaxDegree – oldDegree; tempQuotientCoeffs[newIndex] = quotientCoeffs[i]; } // Add the new quotient term var newTermIndex = targetMaxDegree – quotientTermDegree; tempQuotientCoeffs[newTermIndex] += quotientTermCoeff; quotientCoeffs = trimLeadingZeros(tempQuotientCoeffs); // Calculate product: (quotient term) * divisor var productCoeffs = multiplyPolynomialByTerm(divisorCoeffs, quotientTermCoeff, quotientTermDegree); // Subtract product from current remainder var nextRemainder = subtractPolynomials(currentRemainder, productCoeffs); // Store step details stepsHtml += "Step " + stepNum + ":
"; stepsHtml += "Current Dividend:" + formatPolynomial(currentRemainder) + "";
stepsHtml += "Divisor: " + formatPolynomial(divisorCoeffs) + "";
stepsHtml += "Divide leading terms: (" + formatPolyTerm(leadingRemainderCoeff, currentRemainderDegree) + ") / (" + formatPolyTerm(leadingDivisorCoeff, divisorDegree) + ") = " + formatPolyTerm(quotientTermCoeff, quotientTermDegree) + "";
stepsHtml += "Multiply this term by Divisor: (" + formatPolyTerm(quotientTermCoeff, quotientTermDegree) + ") * (" + formatPolynomial(divisorCoeffs) + ") = " + formatPolynomial(productCoeffs) + "";
stepsHtml += "Subtract Product from Current Dividend: (" + formatPolynomial(currentRemainder) + ") - (" + formatPolynomial(productCoeffs) + ") = " + formatPolynomial(nextRemainder) + "";
stepsHtml += "New Remainder: " + formatPolynomial(nextRemainder) + "";
stepsHtml += "Current Quotient: " + formatPolynomial(quotientCoeffs) + "";
stepsHtml += "Results:
"; resultDiv.innerHTML += "Quotient:" + formatPolynomial(quotientCoeffs) + "";
resultDiv.innerHTML += "Remainder: " + formatPolynomial(currentRemainder) + "";
resultDiv.innerHTML += stepsHtml;
}