{
  "schemaVersion": 1,
  "slug": "cube-root-calculator",
  "category": "math",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "7e4a24cb95633f7ba19f5b3984a9867d2a15334c3adf1c8444faefa7707474a4",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/cube-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": "∛v = sgn(v) × |v|^(1/3)",
    "vars": [
      [
        "v",
        "Input number"
      ],
      [
        "n",
        "Degree of the n-th root"
      ]
    ],
    "note": "Cube roots support negative values. An even-degree real root of a negative value is undefined and is returned as unavailable."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const v=Number(value),r=Number(root),empty={cubeRoot:null,cubed:null,nthRoot:null};if(!Number.isFinite(v)||!Number.isInteger(r)||r<2||r>100)return{...empty,__error:'inputError'};const sign=v<0?-1:1;return{cubeRoot:sign*Math.pow(Math.abs(v),1/3),cubed:v*v*v,nthRoot:v<0&&r%2===0?null:sign*Math.pow(Math.abs(v),1/r),__error:v<0&&r%2===0?'inputError':undefined};",
    "inputs": [
      {
        "name": "value",
        "type": "number",
        "default": 27,
        "min": -1000000000000000,
        "max": 1000000000000000,
        "step": 0.0001,
        "requiredValue": true
      },
      {
        "name": "root",
        "type": "number",
        "default": 3,
        "min": 2,
        "max": 100,
        "step": 1,
        "requiredValue": true
      }
    ],
    "outputs": [
      {
        "name": "cubeRoot",
        "precision": 6,
        "unit": "",
        "showWhen": {
          "root": [
            "3"
          ]
        },
        "trimTrailingZeros": true
      },
      {
        "name": "nthRoot",
        "precision": 6,
        "unit": "",
        "optional": true,
        "showWhen": {
          "root": [
            "2",
            "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"
          ]
        },
        "trimTrailingZeros": true
      },
      {
        "name": "cubed",
        "precision": 6,
        "unit": "",
        "trimTrailingZeros": true
      }
    ],
    "interpret": null
  }
}
