{
  "schemaVersion": 1,
  "slug": "square-root-calculator",
  "category": "math",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "b5bc37b3324f0d649a064f8392dd56b03f42c7b080d7a96bf0c5c81eb53cd810",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/square-root-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": "y = √x (x ≥ 0); yₙ = sgn(x)·|x|^(1÷n); n ∈ ℤ, 2 ≤ n ≤ 100; x < 0 ⇒ n ∈ {3,5,…,99}",
    "vars": [
      [
        "x",
        "Input number"
      ],
      [
        "n",
        "Integer root degree, from 2 to 100"
      ],
      [
        "y",
        "Nonnegative principal square root"
      ],
      [
        "yₙ",
        "Real nth root for the selected degree"
      ]
    ],
    "note": "The √ symbol gives the nonnegative principal square root. Negative inputs require an odd root degree for a real answer. The separate simplified radical always describes the square root, and is available for nonnegative integer inputs up to 1,000,000,000,000. Decimal roots and the verification are approximate."
  },
  "externalEvidence": {
    "reviewedAt": "2026-10-01",
    "sources": [
      {
        "name": "Wolfram MathWorld — Square Root",
        "url": "https://mathworld.wolfram.com/SquareRoot.html"
      }
    ]
  },
  "contract": {
    "compute": "const base={sqrt:Number.isFinite(value)&&value>=0?Math.sqrt(value):null,nthRoot:null,cubeRoot:Number.isFinite(value)?Math.cbrt(value):null,squared:Number.isFinite(value)?value*value:null,simplifiedRoot:null,verification:null};\nif(!Number.isFinite(value)||Math.abs(value)>1e15||!Number.isInteger(root)||root<2||root>100||!Number.isInteger(precision)||precision<0||precision>12)return {...base,__error:'inputError'};\nif(value<0&&root%2===0)return {...base,__error:'realRootError'};\nlet r=root===2?Math.sqrt(value):root===3?Math.cbrt(value):Math.sign(value)*Math.pow(Math.abs(value),1/root);\nconst nearest=Math.round(r);if(Math.pow(nearest,root)===value)r=nearest;\nlet simplifiedRoot=null;if(Number.isSafeInteger(value)&&value>=0&&value<=1e12){let n=value,outside=1,inside=1;if(n===0)simplifiedRoot='0';else{for(let p=2;p*p<=n;p+=(p===2?1:2)){let e=0;while(n%p===0){n/=p;e++;}outside*=Math.pow(p,Math.floor(e/2));if(e%2)inside*=p;}inside*=n;simplifiedRoot=inside===1?String(outside):(outside===1?'':String(outside))+'√'+inside;}}\nconst check=Math.pow(r,root);return {...base,nthRoot:r,simplifiedRoot,verification:'('+String(Number(r.toPrecision(15)))+')^'+root+' ≈ '+String(value)};",
    "inputs": [
      {
        "name": "value",
        "type": "number",
        "default": 144,
        "min": -1000000000000000,
        "max": 1000000000000000,
        "step": "any",
        "requiredValue": true,
        "strictRange": true
      },
      {
        "name": "root",
        "type": "number",
        "default": 2,
        "min": 2,
        "max": 100,
        "step": 1,
        "requiredValue": true,
        "strictRange": true
      },
      {
        "name": "precision",
        "type": "number",
        "default": 6,
        "min": 0,
        "max": 12,
        "step": 1,
        "requiredValue": true,
        "strictRange": true,
        "advanced": true
      }
    ],
    "outputs": [
      {
        "name": "sqrt",
        "precision": 6,
        "unit": "",
        "optional": true,
        "notation": "auto",
        "precisionField": "precision",
        "trimTrailingZeros": true
      },
      {
        "name": "nthRoot",
        "precision": 6,
        "unit": "",
        "optional": true,
        "notation": "auto",
        "precisionField": "precision",
        "trimTrailingZeros": true,
        "showWhen": {
          "root": [
            "3",
            "4",
            "5",
            "6",
            "7",
            "8",
            "9",
            "10",
            "11",
            "12",
            "13",
            "14",
            "15",
            "16",
            "17",
            "18",
            "19",
            "20",
            "21",
            "22",
            "23",
            "24",
            "25",
            "26",
            "27",
            "28",
            "29",
            "30",
            "31",
            "32",
            "33",
            "34",
            "35",
            "36",
            "37",
            "38",
            "39",
            "40",
            "41",
            "42",
            "43",
            "44",
            "45",
            "46",
            "47",
            "48",
            "49",
            "50",
            "51",
            "52",
            "53",
            "54",
            "55",
            "56",
            "57",
            "58",
            "59",
            "60",
            "61",
            "62",
            "63",
            "64",
            "65",
            "66",
            "67",
            "68",
            "69",
            "70",
            "71",
            "72",
            "73",
            "74",
            "75",
            "76",
            "77",
            "78",
            "79",
            "80",
            "81",
            "82",
            "83",
            "84",
            "85",
            "86",
            "87",
            "88",
            "89",
            "90",
            "91",
            "92",
            "93",
            "94",
            "95",
            "96",
            "97",
            "98",
            "99",
            "100"
          ]
        }
      },
      {
        "name": "simplifiedRoot",
        "precision": 0,
        "unit": "",
        "type": "text",
        "optional": true,
        "display": "tokens"
      },
      {
        "name": "verification",
        "precision": 0,
        "unit": "",
        "type": "text",
        "optional": true
      },
      {
        "name": "cubeRoot",
        "precision": 6,
        "unit": "",
        "notation": "auto",
        "precisionField": "precision",
        "trimTrailingZeros": true
      },
      {
        "name": "squared",
        "precision": 6,
        "unit": "",
        "notation": "auto",
        "precisionField": "precision",
        "trimTrailingZeros": true
      }
    ],
    "interpret": null
  }
}
