{
  "id": "area",
  "version": "686c7671252d",
  "status": "published",
  "name": "Area Calculator",
  "question": "What is the area of a shape?",
  "summary": "Finds the area of a rectangle, square, triangle, circle, ellipse, trapezoid, parallelogram, circle sector, or regular polygon from its measurements.",
  "category": "math",
  "subcategory": "geometry",
  "url": "https://www.acalculator.org/math/area-calculator",
  "markdown": "https://www.acalculator.org/math/area-calculator.md",
  "kind": "function",
  "method": "A = the shape’s standard area formula, for example A = l × w for a rectangle and A = πr² for a circle.",
  "assumptions": [
    "Every length is more than 0 and all are in the same unit; the area is in that unit squared.",
    "A height is measured at right angles to the base.",
    "Three sides must make a triangle: each side shorter than the other two together.",
    "A regular polygon has n equal sides and equal angles; a sector angle is more than 0 and at most 360°."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "shape": {
        "title": "Shape",
        "description": "The flat shape to find the area of.",
        "type": "string",
        "enum": [
          "rectangle",
          "square",
          "triangle",
          "triangle3",
          "circle",
          "ellipse",
          "trapezoid",
          "parallelogram",
          "sector",
          "polygon"
        ]
      },
      "l": {
        "title": "Length (l)",
        "description": "The length of the rectangle.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "w": {
        "title": "Width (w)",
        "description": "The width of the rectangle.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "s": {
        "title": "Side (s)",
        "description": "The length of each side.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "b": {
        "title": "Base (b)",
        "description": "The length of the base (for a trapezoid, one of the two parallel sides).",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "t": {
        "title": "Top (t)",
        "description": "The other parallel side of the trapezoid.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "h": {
        "title": "Height (h)",
        "description": "The height, at right angles to the base.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "sa": {
        "title": "Side a",
        "description": "The first side of the triangle.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "sb": {
        "title": "Side b",
        "description": "The second side of the triangle.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "sc": {
        "title": "Side c",
        "description": "The third side of the triangle.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "r": {
        "title": "Radius (r)",
        "description": "The radius of the circle.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "a": {
        "title": "Semi-axis a",
        "description": "Half the length of the ellipse, along its longest or shortest axis.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "b2": {
        "title": "Semi-axis b",
        "description": "Half the length of the ellipse along the other axis.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "angle": {
        "title": "Angle in degrees (θ)",
        "description": "The angle of the sector at the centre of the circle, in degrees, up to 360.",
        "type": "number",
        "exclusiveMinimum": 0,
        "maximum": 360
      },
      "n": {
        "title": "Number of sides (n)",
        "description": "How many equal sides the regular polygon has, from 3 to 1,000.",
        "type": "integer",
        "minimum": 3,
        "maximum": 1000
      }
    }
  },
  "outputs": {
    "area": {
      "label": "Area",
      "description": "The space inside the shape, in the square of the length unit (cm gives cm²).",
      "format": "number"
    },
    "formula": {
      "label": "Formula",
      "description": "The area formula for this shape.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "shape": "rectangle",
      "l": 12,
      "w": 8,
      "s": 5,
      "b": 10,
      "t": 6,
      "h": 4,
      "sa": 5,
      "sb": 6,
      "sc": 7,
      "r": 3,
      "a": 5,
      "b2": 3,
      "angle": 60,
      "n": 6
    },
    "outputs": {
      "area": 96,
      "formula": "A = l × w"
    },
    "text": "Rectangle area: 96 square units."
  },
  "examples": [
    {
      "given": {
        "shape": "rectangle",
        "l": 12,
        "w": 8
      },
      "expect": {
        "area": 96,
        "formula": "A = l × w"
      },
      "source": "hand calculation in content.mdx: 12 × 8 = 96"
    },
    {
      "given": {
        "shape": "square",
        "s": 5
      },
      "expect": {
        "area": 25
      },
      "source": "hand calculation in content.mdx: 5² = 25"
    },
    {
      "given": {
        "shape": "triangle",
        "b": 10,
        "h": 4
      },
      "expect": {
        "area": 20
      },
      "source": "hand calculation in content.mdx: 10 × 4 ÷ 2 = 20"
    },
    {
      "given": {
        "shape": "triangle3",
        "sa": 5,
        "sb": 6,
        "sc": 7
      },
      "expect": {
        "area": 14.696938456699069
      },
      "source": "hand calculation in content.mdx: p = 9, √(9 × 4 × 3 × 2) = √216 = 6√6; Python 3: math.sqrt(216) = 14.696938456699069"
    },
    {
      "given": {
        "shape": "circle",
        "r": 3
      },
      "expect": {
        "area": 28.274333882308138
      },
      "source": "hand calculation in content.mdx: π × 9; Python 3: math.pi * 9 = 28.274333882308138"
    },
    {
      "given": {
        "shape": "ellipse",
        "a": 5,
        "b2": 3
      },
      "expect": {
        "area": 47.12388980384689
      },
      "source": "hand calculation in content.mdx: π × 15; Python 3: math.pi * 15 = 47.12388980384689"
    },
    {
      "given": {
        "shape": "trapezoid",
        "b": 10,
        "t": 6,
        "h": 4
      },
      "expect": {
        "area": 32
      },
      "source": "hand calculation in content.mdx: (10 + 6) × 4 ÷ 2 = 32"
    },
    {
      "given": {
        "shape": "parallelogram",
        "b": 10,
        "h": 4
      },
      "expect": {
        "area": 40
      },
      "source": "hand calculation in content.mdx: 10 × 4 = 40"
    },
    {
      "given": {
        "shape": "sector",
        "r": 3,
        "angle": 60
      },
      "expect": {
        "area": 4.71238898038469
      },
      "source": "hand calculation in content.mdx: (π/3) × 9 ÷ 2 = 1.5π; Python 3: (math.pi / 3) * 9 / 2 = 4.71238898038469"
    },
    {
      "given": {
        "shape": "polygon",
        "n": 6,
        "s": 5
      },
      "expect": {
        "area": 64.95190528383291
      },
      "source": "hand calculation in content.mdx: 6 × 25 ÷ (4 tan 30°) = 75√3 ÷ 2; Python 3: 6 * 25 / (4 * math.tan(math.pi / 6)) = 64.95190528383291"
    }
  ],
  "sources": [
    "OpenStax, Prealgebra 2e, section 9.4 Use Properties of Rectangles, Triangles, and Trapezoids: https://openstax.org/books/prealgebra-2e/pages/9-4-use-properties-of-rectangles-triangles-and-trapezoids",
    "OpenStax, Prealgebra 2e, section 9.5 Solve Geometry Applications: Circles and Irregular Figures: https://openstax.org/books/prealgebra-2e/pages/9-5-solve-geometry-applications-circles-and-irregular-figures",
    "OpenStax, Algebra and Trigonometry 2e, section 10.2 Non-right Triangles: Law of Cosines (Heron's formula): https://openstax.org/books/algebra-and-trigonometry-2e/pages/10-2-non-right-triangles-law-of-cosines",
    "OpenStax, Algebra and Trigonometry 2e, section 7.1 Angles (area of a sector): https://openstax.org/books/algebra-and-trigonometry-2e/pages/7-1-angles"
  ],
  "related": [
    "volume",
    "pythagorean-theorem"
  ],
  "changelog": []
}
