{
  "id": "equation-solver",
  "version": "78f745968bba",
  "status": "published",
  "name": "Equation Solver",
  "question": "How do you solve an equation?",
  "summary": "Lists every real solution of an equation, exact where possible, each checked.",
  "category": "math",
  "subcategory": "algebra",
  "url": "https://www.acalculator.org/math/equation-solver",
  "markdown": "https://www.acalculator.org/math/equation-solver.md",
  "kind": "function",
  "method": "A computer algebra system; each root is checked, and a numeric scan finds any missed.",
  "assumptions": [
    "Only real solutions; no answer for sin, cos or tan of the variable."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "eq": {
        "title": "Equation",
        "description": "The equation, in one letter.",
        "type": "string",
        "maxLength": 200
      }
    }
  },
  "outputs": {
    "solutions": {
      "label": "Solutions",
      "description": "Every real solution.",
      "format": "text"
    },
    "decimals": {
      "label": "As decimals",
      "description": "Each solution as a decimal.",
      "format": "text"
    },
    "count": {
      "label": "Number of real solutions",
      "description": "How many there are.",
      "format": "integer"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "eq": "x^2 - 3x - 5 = 0"
    },
    "outputs": {
      "solutions": "x = 3/2 - sqrt(29)/2, x = sqrt(29)/2 + 3/2",
      "decimals": "x ≈ -1.192582404, x ≈ 4.192582404",
      "count": 2
    },
    "text": "Solving x^2 - 3x - 5 = 0 gives x = 3/2 - sqrt(29)/2, x = sqrt(29)/2 + 3/2."
  },
  "examples": [
    {
      "given": {
        "eq": "x^2 - 3x - 5 = 0"
      },
      "expect": {
        "solutions": "x = 3/2 - sqrt(29)/2, x = sqrt(29)/2 + 3/2",
        "decimals": "x ≈ -1.192582404, x ≈ 4.192582404",
        "count": 2
      },
      "source": "OpenStax College Algebra 2e, 2.5, Ex. 8. https://openstax.org/books/college-algebra-2e/pages/2-5-quadratic-equations"
    },
    {
      "given": {
        "eq": "4x^2 + 15x + 9 = 0"
      },
      "expect": {
        "solutions": "x = -3, x = -3/4",
        "count": 2
      },
      "source": "OpenStax College Algebra 2e, 2.5, Ex. 4"
    }
  ],
  "sources": [
    "OpenStax, College Algebra 2e, section 2.5 Quadratic Equations: https://openstax.org/books/college-algebra-2e/pages/2-5-quadratic-equations",
    "OpenStax, College Algebra 2e, section 2.2 Linear Equations in One Variable: https://openstax.org/books/college-algebra-2e/pages/2-2-linear-equations-in-one-variable",
    "NIST Digital Library of Mathematical Functions, section 1.11 Zeros of Polynomials: https://dlmf.nist.gov/1.11"
  ],
  "related": [
    "algebra",
    "solve-for-x",
    "quadratic-formula",
    "factoring",
    "math"
  ],
  "changelog": []
}
