{
  "id": "polynomial",
  "version": "c0c4cb441a04",
  "status": "published",
  "name": "Polynomial Calculator",
  "question": "How do I add or divide polynomials?",
  "summary": "Adds, subtracts, multiplies and divides polynomials in exact fractions, and finds their real zeros.",
  "category": "math",
  "subcategory": "algebra",
  "url": "https://www.acalculator.org/math/polynomial-calculator",
  "markdown": "https://www.acalculator.org/math/polynomial-calculator.md",
  "kind": "function",
  "method": "Exact fractions throughout: terms are multiplied out and like terms added; division is polynomial long division.",
  "assumptions": [
    "Coefficients are exact fractions: 0.1 is 1/10.",
    "Zeros that are not fractions are decimals to 10 significant figures, marked ≈."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "p": {
        "title": "Polynomial p",
        "description": "A polynomial in one letter.",
        "type": "string",
        "maxLength": 200
      },
      "op": {
        "title": "Operation",
        "description": "What to do with p and q.",
        "type": "string",
        "enum": [
          "divide",
          "multiply",
          "add",
          "subtract",
          "zeros"
        ]
      },
      "q": {
        "title": "Polynomial q",
        "description": "The second polynomial, in the same letter.",
        "type": "string",
        "maxLength": 200
      }
    }
  },
  "outputs": {
    "result": {
      "label": "Result",
      "description": "The sum, difference, product or quotient.",
      "format": "math"
    },
    "remainder": {
      "label": "Remainder",
      "description": "What is left after division.",
      "format": "math"
    },
    "zeros": {
      "label": "Real zeros",
      "description": "Exact fractions, or decimals marked ≈.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "p": "6x^3 + 11x^2 - 31x + 15",
      "op": "divide",
      "q": "3x - 2"
    },
    "outputs": {
      "result": "2x^2 + 5x - 7",
      "remainder": "1"
    },
    "text": "The result is 2x^2 + 5x - 7."
  },
  "examples": [
    {
      "given": {
        "p": "6x^3 + 11x^2 - 31x + 15",
        "op": "divide",
        "q": "3x - 2"
      },
      "expect": {
        "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"
    },
    {
      "given": {
        "p": "2x + 1",
        "op": "multiply",
        "q": "3x^2 - x + 4"
      },
      "expect": {
        "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"
    }
  ],
  "sources": [
    "OpenStax, College Algebra 2e, section 1.4 Polynomials: https://openstax.org/books/college-algebra-2e/pages/1-4-polynomials",
    "OpenStax, College Algebra 2e, section 5.4 Dividing Polynomials: https://openstax.org/books/college-algebra-2e/pages/5-4-dividing-polynomials",
    "OpenStax, College Algebra 2e, section 5.5 Zeros of Polynomial Functions: https://openstax.org/books/college-algebra-2e/pages/5-5-zeros-of-polynomial-functions"
  ],
  "related": [
    "combine-like-terms",
    "factoring",
    "equation-solver",
    "partial-fraction"
  ],
  "changelog": []
}
