algebra25 min

Polynomials

Polynomial structure, degree, leading coefficients, and arithmetic operations on polynomials

0/9Not Started

Why This Matters

A polynomial is an expression built from variables and coefficients using only addition, subtraction, and multiplication -- no division by variables, no square roots of variables. Polynomials like 3x^4 - 2x^2 + x - 7 are the workhorses of algebra because they are simple enough to analyze yet powerful enough to model curves, approximate functions, and describe physical phenomena.

The degree of a polynomial is the highest power of the variable that appears. A degree-1 polynomial is a line, degree-2 is a parabola, degree-3 is a cubic curve, and so on. The leading coefficient -- the coefficient of the highest-power term -- controls whether the curve opens up or down and how quickly it grows. Knowing the degree and leading coefficient tells you a lot about a polynomial before you ever graph it.

Polynomial arithmetic -- adding, subtracting, and multiplying polynomials -- is the algebraic equivalent of combining and composing functions. In computer science, polynomials appear in error-correcting codes, cryptographic algorithms, interpolation, and the analysis of algorithm running times.

Define Terms

Visual Model

Terms3x^4, -2x^2, x, -7
Degree: 4Highest exponent
Leading Coeff: 3Coeff of x^4
Polynomial3x^4 - 2x^2 + x - 7
AdditionCombine like terms
MultiplicationDistribute and collect
New PolynomialHigher degree possible

The full process at a glance. Click Start tour to walk through each step.

Polynomials are sums of terms. Their degree and leading coefficient determine shape and growth.

Code Example

Code
// Represent polynomials as coefficient arrays
// Index = power: [constant, x, x^2, x^3, ...]

// 3x^2 + 2x + 1 = [1, 2, 3]
const p1 = [1, 2, 3];

// x^2 - 4x + 5 = [5, -4, 1]
const p2 = [5, -4, 1];

// Get degree (highest non-zero index)
function degree(poly) {
  for (let i = poly.length - 1; i >= 0; i--) {
    if (poly[i] !== 0) return i;
  }
  return 0;
}
console.log("Degree of p1:", degree(p1)); // 2

// Leading coefficient
function leadingCoefficient(poly) {
  return poly[degree(poly)];
}
console.log("Leading coeff of p1:", leadingCoefficient(p1)); // 3

// Add two polynomials
function addPolynomials(a, b) {
  const maxLen = Math.max(a.length, b.length);
  const result = [];
  for (let i = 0; i < maxLen; i++) {
    result.push((a[i] || 0) + (b[i] || 0));
  }
  return result;
}
console.log("p1 + p2:", addPolynomials(p1, p2)); // [6, -2, 4]

// Multiply two polynomials
function multiplyPolynomials(a, b) {
  const result = new Array(a.length + b.length - 1).fill(0);
  for (let i = 0; i < a.length; i++) {
    for (let j = 0; j < b.length; j++) {
      result[i + j] += a[i] * b[j];
    }
  }
  return result;
}
// (x + 2)(x + 3) = x^2 + 5x + 6
console.log("(x+2)(x+3):", multiplyPolynomials([2, 1], [3, 1])); // [6, 5, 1]
console.log("p1 * p2:", multiplyPolynomials(p1, p2));

Interactive Experiment

Try these exercises:

  • Create a polynomial of degree 5. What is its leading coefficient? How many terms does it have at most?
  • Add [1, 3, -2] and [4, -3, 2, 1]. What is the degree of the result?
  • Multiply [1, 1] by itself three times to get (x + 1)^3. Verify the result is [1, 3, 3, 1].
  • What is the degree of the product of a degree-2 and a degree-3 polynomial?
  • Create a polynomial that equals zero when x = 2. Hint: (x - 2) = [-2, 1] is a factor.

Quick Quiz

Coding Challenge

Polynomial Arithmetic

Write two functions: `addPoly` takes two coefficient arrays and returns their sum, and `multiplyPoly` takes two coefficient arrays and returns their product. Coefficient arrays use index = power, so [6, 5, 1] represents x^2 + 5x + 6. For example, addPoly([1, 2], [3, -1, 4]) should return [4, 1, 4] and multiplyPoly([1, 1], [1, 1]) should return [1, 2, 1].

Loading editor...

Real-World Usage

Polynomials are fundamental tools across science and engineering:

  • Computer graphics: Bezier curves and splines are piecewise polynomials that define smooth curves for fonts, animations, and CAD.
  • Error correction: Reed-Solomon codes (used in QR codes, CDs, and deep-space communication) use polynomial arithmetic over finite fields.
  • Signal processing: Polynomial interpolation reconstructs signals from sampled data points.
  • Cryptography: Shamir secret sharing splits a secret into pieces using polynomial evaluation at different points.
  • Algorithm analysis: Running times like O(n^2 + 3n + 1) are polynomials in n, and we simplify to the dominant term.

Connections