acalculator

How do I add or divide polynomials?

Type a polynomial p, pick an operation, and type q. Division gives the quotient and the remainder; Zeros of p lists the real zeros.

Your numbers

Operation
Result
2x^2 + 5x - 7

The result is 2x^2 + 5x - 7.

Remainder
1

Result: 2x^2 + 5x - 7. The result is 2x^2 + 5x - 7.

How to calculate

Adds, subtracts, multiplies and divides polynomials in exact fractions, and finds their real zeros.

Example with the default inputs (Polynomial p 6x^3 + 11x^2 - 31x + 15, Operation p ÷ q, Polynomial q 3x - 2): The result is 2x^2 + 5x - 7.

Method: Exact fractions throughout: terms are multiplied out and like terms added; division is polynomial long division.

  • Coefficients are exact fractions: 0.1 is 1/10.
  • Zeros that are not fractions are decimals to 10 significant figures, marked ≈.

Machine-readable copies: Markdown, JSON.

Worked examples

Each example is checked against the calculator on every build.

  1. Polynomial p 6x^3 + 11x^2 - 31x + 15, Operation p ÷ q, Polynomial q 3x - 2 gives Result 2x^2 + 5x - 7, Remainder 1.Source: OpenStax College Algebra 2e, 5.4, Example 2. https://openstax.org/books/college-algebra-2e/pages/5-4-dividing-polynomials
  2. Polynomial p 2x + 1, Operation p × q, Polynomial q 3x^2 - x + 4 gives Result 6x^3 + x^2 + 7x + 4.Source: OpenStax College Algebra 2e, 1.4, Example 4. https://openstax.org/books/college-algebra-2e/pages/1-4-polynomials

How it works

Every coefficient is an exact fraction, so there is no rounding in the algebra. Each polynomial is multiplied out and its like terms are added before the operation.

  • p + q, p − q, p × q: term by term, like terms added.
  • p ÷ q: polynomial long division. While what is left has degree at least deg q, divide its leading coefficient by the leading coefficient of q, subtract that multiple of q times the right power of the letter, and add the term to the quotient. The result satisfies p = q × quotient + remainder with deg(remainder) less than deg(q). Division by q = 0 gives a message.
  • Zeros of p: the distinct real zeros. The page takes the square-free part s = p ÷ gcd(p, p′) (exact), whose zeros are those of p, each once. While s has degree 2 or more, it finds the complex roots of s numerically (Durand-Kerner iteration, 800 rounds, starting on a circle whose radius is Fujiwara’s bound 2 × max |aₙ₋ₖ/aₙ|^(1/k), with a₀ halved). For each root whose imaginary part is within 10⁻⁷ × max(1, |real part|) of 0, it tries in turn the convergents of the continued fraction of the real part that lie within 10⁻³ × max(1, |root|) of it, with denominators up to 10¹²; a convergent r is a zero when s divided by (x − r) leaves remainder exactly 0. Then s is divided by (x − r) and the roots are found again. When s has degree 1, its zero −s₀/s₁ is a fraction. When a round finds no fraction, each real root left is a decimal after 5 Newton steps on s, to 10 significant figures, marked ≈, but only when its error bound (|s(x)| + 10⁻¹⁵ × the sum of the sizes of the terms of s) / |s′(x)| is at most 10⁻¹³ × max(1, |x|); otherwise the page says "No verified answer: some real zeros could not be confirmed to 10 significant figures (they are very close together, or very sensitive to rounding)." Last, the page counts the distinct real zeros of p exactly by Sturm’s theorem: for p, p′ and the exact remainders rᵢ of the Euclidean algorithm on them, the count is V(−∞) − V(+∞), where V is the number of sign changes of (−1)^⌊i/2⌋ rᵢ. If the count differs from the number of zeros found (zeros closer together than the numeric roots can separate look complex), the page gives the same message. Degrees up to 20.

What you can type

  • One letter, the same in p and q: any lowercase letter except e. The constants e and π are not allowed, as a letter or in a coefficient.
  • Numbers can have decimals (2.5 is 5/2) and powers of ten (1e-3). Fractions such as 3/4 are exact.
  • Operations: + − * / and ^ with whole-number powers (a power of the letter up to 100, a bracket with a sum up to the 20th power); brackets group; numbers and letters side by side multiply (2x, 3(x + 1)). Dividing by a number is fine; dividing by an expression with the letter is not a polynomial.

How answers are written

  • Result and Remainder: polynomials in the syntax you type, as MathML, highest power first: 2x^2 + 5x − 7. A coefficient that is a fraction is written over the term: 5x/6 means (5/6)x, and 3x^2/4 means (3/4)x². The remainder of an exact division is 0.
  • Real zeros: "x = −1/2, x = 1, x ≈ 1.414213562" in increasing order, fractions exact (in lowest terms), decimals to 10 significant figures after ≈; "No real zeros" when there are none. Complex zeros are not listed.

Assumptions

  • Coefficients are exact fractions: 0.1 is 1/10.
  • A zero that is not a fraction is a decimal to 10 significant figures.

Worked examples by hand

(6x³ + 11x² − 31x + 15) ÷ (3x − 2) (OpenStax College Algebra 2e, section 5.4, Example 2). 6x³ ÷ 3x = 2x²; subtract 2x²(3x − 2) = 6x³ − 4x² to leave 15x² − 31x + 15. 15x² ÷ 3x = 5x; subtract 15x² − 10x to leave −21x + 15. −21x ÷ 3x = −7; subtract −21x + 14 to leave 1. Quotient 2x² + 5x − 7, remainder 1.

(2x + 1)(3x² − x + 4) (section 1.4, Example 4). 2x(3x² − x + 4) + 1(3x² − x + 4) = 6x³ − 2x² + 8x + 3x² − x + 4 = 6x³ + x² + 7x + 4.

Zeros of 4x³ − 3x − 1 (section 5.5, Example 5). x = 1 is a zero: 4 − 3 − 1 = 0. Dividing by x − 1 gives 4x² + 4x + 1 = (2x + 1)², so the other zero is −1/2 (twice). The page lists x = −1/2, x = 1.

Other questions people ask

How do I divide polynomials?

Choose p ÷ q. The page does polynomial long division: it divides the leading term of p by the leading term of q, subtracts that multiple of q, and repeats until what is left has a lower degree than q. The result is the quotient, and what is left is the remainder, so p = q × quotient + remainder. For (6x³ + 11x² − 31x + 15) ÷ (3x − 2) the quotient is 2x² + 5x − 7 and the remainder is 1.

How do I multiply polynomials?

Choose p × q. Every term of p is multiplied by every term of q and like terms are added: (2x + 1)(3x² − x + 4) = 6x³ − 2x² + 8x + 3x² − x + 4 = 6x³ + x² + 7x + 4.

How are the zeros found?

The page finds the roots of p numerically and tries simple fractions next to each real one; a fraction counts only when dividing p by (x − fraction) leaves remainder exactly 0, so x = 10000001/10000000 means exactly that. After each fraction zero it divides it out and looks again, and the last zero of a linear factor is always a fraction. Real zeros that are not fractions, such as √2, show as decimals marked ≈, and only when the page can bound their error to 10 significant figures. The page also counts the distinct real zeros exactly (Sturm’s theorem) and answers only when it found that many. A repeated zero is listed once.

Can I use fractions and decimals?

Yes. Coefficients are exact: 0.1 is 1/10 and x/3 is (1/3)x, and the answers use exact fractions such as 5x/6. A decimal such as 0.1 is never rounded along the way.

Which polynomials can I type?

Any polynomial in one letter (x, t, or another letter except e) with whole-number powers, typed expanded or not: 2x^3 - 3x + 5, (x - 1)(x + 2)^2, x^2/4 + 1. p and q must use the same letter. Division by a letter, such as 1/x, is not a polynomial and gives a message.

What is the degree of a polynomial?

The highest power of the letter with a nonzero coefficient. The degree of a product is the sum of the degrees; in a division the quotient has degree deg p − deg q, and the remainder has a lower degree than q.