{
  "schemaVersion": 1,
  "slug": "quadratic-equation-calculator",
  "category": "math",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "6296259f219b33f8fc76e8e25aa06801424643951c04cdfac831bf9cf7bba815",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/quadratic-equation-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "D = b² − 4ac; x = (−b ± √D) ÷ 2a when D ≥ 0",
    "vars": [
      [
        "a",
        "Coefficient a"
      ],
      [
        "b",
        "Coefficient b"
      ],
      [
        "c",
        "Constant c"
      ],
      [
        "D",
        "Discriminant"
      ],
      [
        "x",
        "Real roots"
      ],
      [
        "xᵥ",
        "Vertex x-coordinate"
      ],
      [
        "yᵥ",
        "Vertex y-coordinate"
      ]
    ],
    "note": "a must be nonzero. If D < 0, the real-root fields are blank because no real roots exist."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "if(a===0)return {__error:'inputError',discriminant:null,root1:null,root2:null,vertexX:null,vertexY:null,sumOfRoots:null}; const disc=b*b-4*a*c; const sq=disc>=0?Math.sqrt(disc):0; let plus=null,minus=null; if(disc>=0){const stable=-0.5*(b+(b>=0?sq:-sq));if(stable===0){plus=(-b+sq)/(2*a);minus=(-b-sq)/(2*a)}else{const r=stable/a,other=c/stable;if(b>=0){minus=r;plus=other}else{plus=r;minus=other}}} return {discriminant:disc,root1:plus,root2:minus,vertexX:-b/(2*a),vertexY:c-b*b/(4*a),sumOfRoots:-b/a};",
    "inputs": [
      {
        "name": "a",
        "type": "number",
        "default": 1,
        "min": -1000000000,
        "max": 1000000000,
        "step": 0.01
      },
      {
        "name": "b",
        "type": "number",
        "default": -3,
        "min": -1000000000,
        "max": 1000000000,
        "step": 0.01
      },
      {
        "name": "c",
        "type": "number",
        "default": 2,
        "min": -1000000000,
        "max": 1000000000,
        "step": 0.01
      }
    ],
    "outputs": [
      {
        "name": "discriminant",
        "precision": 4,
        "unit": ""
      },
      {
        "name": "root1",
        "precision": 12,
        "trimTrailingZeros": true,
        "unit": "",
        "optional": true
      },
      {
        "name": "root2",
        "precision": 12,
        "trimTrailingZeros": true,
        "unit": "",
        "optional": true
      },
      {
        "name": "vertexX",
        "precision": 6,
        "unit": ""
      },
      {
        "name": "vertexY",
        "precision": 6,
        "unit": ""
      },
      {
        "name": "sumOfRoots",
        "precision": 6,
        "unit": ""
      }
    ],
    "interpret": null
  }
}
