{
  "schemaVersion": 1,
  "slug": "pythagorean-theorem-calculator",
  "category": "geometry",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "f3769d546c869e36dc38fa41f1b9c3b7be2cad1bb3c36720d62da1af43a34e05",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/pythagorean-theorem-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": "c = √(a² + b²); b = √(c² − a²); S = a×b÷2; P = a+b+c",
    "vars": [
      [
        "a",
        "Leg a"
      ],
      [
        "b",
        "Leg b"
      ],
      [
        "c",
        "Hypotenuse c"
      ],
      [
        "S",
        "Area"
      ],
      [
        "P",
        "Perimeter"
      ]
    ],
    "note": "Enter exactly two positive side lengths; leave the unknown side at zero. The hypotenuse must exceed either leg."
  },
  "externalEvidence": {
    "reviewedAt": "2026-10-12",
    "sources": [
      {
        "name": "OpenStax — Pythagorean theorem and right triangles",
        "url": "https://openstax.org/books/prealgebra-2e/pages/9-3-use-properties-of-angles-triangles-and-the-pythagorean-theorem"
      }
    ],
    "referenceRole": "definition",
    "implementationHash": "f3769d546c869e36dc38fa41f1b9c3b7be2cad1bb3c36720d62da1af43a34e05",
    "basis": "c = √(a² + b²); b = √(c² − a²); S = a×b÷2; P = a+b+c",
    "limitations": "The references explain definitions and methods; any extra preset must be checked against the assumptions on this page."
  },
  "contract": {
    "compute": "let A=a,B=b,C=c; const given=[A,B,C].filter(v=>v>0).length; if(given!==2)return {__error:'inputError',hypotenuse:null,sideA:null,sideB:null,area:null,perimeter:null}; if(C>0&&A>0){if(C<=A)return {__error:'inputError',hypotenuse:null,sideA:null,sideB:null,area:null,perimeter:null};B=Math.sqrt(C*C-A*A);} else if(C>0&&B>0){if(C<=B)return {__error:'inputError',hypotenuse:null,sideA:null,sideB:null,area:null,perimeter:null};A=Math.sqrt(C*C-B*B);} else C=Math.sqrt(A*A+B*B); return {__primary:a===0?\"sideA\":b===0?\"sideB\":\"hypotenuse\",hypotenuse:C,sideA:A,sideB:B,area:A*B/2,perimeter:A+B+C};",
    "inputs": [
      {
        "name": "a",
        "type": "number",
        "default": 3,
        "min": 0,
        "max": 1000000000,
        "step": 0.001
      },
      {
        "name": "b",
        "type": "number",
        "default": 4,
        "min": 0,
        "max": 1000000000,
        "step": 0.001
      },
      {
        "name": "c",
        "type": "number",
        "default": 0,
        "min": 0,
        "max": 1000000000,
        "step": 0.001
      }
    ],
    "outputs": [
      {
        "name": "hypotenuse",
        "precision": 4,
        "unit": "cm"
      },
      {
        "name": "sideA",
        "precision": 4,
        "unit": "cm"
      },
      {
        "name": "sideB",
        "precision": 4,
        "unit": "cm"
      },
      {
        "name": "area",
        "precision": 4,
        "unit": "cm²"
      },
      {
        "name": "perimeter",
        "precision": 4,
        "unit": "cm"
      }
    ],
    "interpret": null
  }
}
