{
  "schemaVersion": 1,
  "slug": "area-of-circle-calculator",
  "category": "geometry",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "4f3570f2a4709742fbe6ae6911bee577337daa0f3e85d95b6da5e82311fff4a7",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/area-of-circle-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": "A = π r²; C = 2 π r",
    "vars": [
      [
        "r",
        "Radius"
      ],
      [
        "A",
        "Area"
      ],
      [
        "C",
        "Circumference"
      ]
    ],
    "note": "If a positive diameter d is entered, r = d ÷ 2; otherwise the radius input is used."
  },
  "externalEvidence": {
    "reviewedAt": "2026-10-04",
    "sources": [
      {
        "name": "OpenStax — Geometric formulas",
        "url": "https://openstax.org/books/prealgebra/pages/c-geometric-formulas"
      }
    ],
    "basis": "Area = πr²; circumference = 2πr.",
    "limitations": "Ideal Euclidean shapes; use consistent length units. A diameter is twice the radius.",
    "implementationHash": "4f3570f2a4709742fbe6ae6911bee577337daa0f3e85d95b6da5e82311fff4a7",
    "domain": "math"
  },
  "contract": {
    "compute": "if(!['radius','diameter'].includes(geometryKind)||!Number.isFinite(geometryKind==='diameter'?diameter:radius))return{__error:'inputError'};const r = geometryKind==='diameter'?diameter/2:radius; return { area: Math.PI*r*r, circumference: 2*Math.PI*r, diameter: 2*r, radius: r };",
    "inputs": [
      {
        "name": "geometryKind",
        "type": "select",
        "default": "radius",
        "options": [
          {
            "value": "radius"
          },
          {
            "value": "diameter"
          }
        ]
      },
      {
        "name": "radius",
        "type": "number",
        "default": 10,
        "min": 0,
        "max": 1000000000,
        "step": 0.001,
        "requiredValue": true,
        "showWhen": {
          "geometryKind": [
            "radius"
          ]
        }
      },
      {
        "name": "diameter",
        "type": "number",
        "default": 0,
        "min": 0,
        "max": 1000000000,
        "step": 0.001,
        "requiredValue": true,
        "showWhen": {
          "geometryKind": [
            "diameter"
          ]
        }
      }
    ],
    "outputs": [
      {
        "name": "area",
        "precision": 4,
        "unit": "cm²",
        "trimTrailingZeros": true
      },
      {
        "name": "circumference",
        "precision": 4,
        "unit": "cm",
        "trimTrailingZeros": true
      },
      {
        "name": "diameter",
        "precision": 4,
        "unit": "cm",
        "trimTrailingZeros": true
      },
      {
        "name": "radius",
        "precision": 4,
        "unit": "cm",
        "trimTrailingZeros": true
      }
    ],
    "interpret": null
  }
}
