{
  "id": "triangle-area",
  "version": "18ba5e016abf",
  "status": "published",
  "name": "Area of a Triangle Calculator",
  "question": "What is the area of a triangle?",
  "summary": "Finds the area of a triangle from its base and height, three sides (Heron’s formula), two sides and the angle between them, two angles and a side, or three corner points.",
  "category": "math",
  "subcategory": "geometry",
  "url": "https://www.acalculator.org/math/triangle-area-calculator",
  "markdown": "https://www.acalculator.org/math/triangle-area-calculator.md",
  "kind": "function",
  "method": "A = ½ × base × height; from three sides, Heron’s formula √(s(s − a)(s − b)(s − c)); from two sides and the angle between them, ½ab sin C.",
  "assumptions": [
    "Lengths are positive numbers in any one unit; the area is in that unit squared.",
    "Angles are more than 0° and less than 180°, in degrees or radians.",
    "Corner points are read exactly as typed (0.1 is 1/10), so their area is exact before rounding."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "method": {
        "title": "What do you know?",
        "description": "Which measurements of the triangle you know.",
        "type": "string",
        "enum": [
          "bh",
          "sss",
          "sas",
          "asa",
          "points"
        ]
      },
      "base": {
        "title": "Base",
        "description": "The length of the side the height is measured from.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "height": {
        "title": "Height",
        "description": "The distance from the base to the opposite corner, at a right angle.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "a": {
        "title": "Side a",
        "description": "The length of side a.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "b": {
        "title": "Side b",
        "description": "The length of side b.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "c": {
        "title": "Side c",
        "description": "The length of side c; with two angles, the side between them.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "C": {
        "title": "Angle C",
        "description": "The angle between sides a and b.",
        "type": [
          "number",
          "string"
        ],
        "x-quantity": "angle",
        "exclusiveMinimum": 0,
        "exclusiveMaximum": 3.141592653589793
      },
      "A": {
        "title": "Angle A",
        "description": "One angle next to side c.",
        "type": [
          "number",
          "string"
        ],
        "x-quantity": "angle",
        "exclusiveMinimum": 0,
        "exclusiveMaximum": 3.141592653589793
      },
      "B": {
        "title": "Angle B",
        "description": "The other angle next to side c.",
        "type": [
          "number",
          "string"
        ],
        "x-quantity": "angle",
        "exclusiveMinimum": 0,
        "exclusiveMaximum": 3.141592653589793
      },
      "x1": {
        "title": "x₁",
        "description": "The x coordinate of the first corner.",
        "type": "number"
      },
      "y1": {
        "title": "y₁",
        "description": "The y coordinate of the first corner.",
        "type": "number"
      },
      "x2": {
        "title": "x₂",
        "description": "The x coordinate of the second corner.",
        "type": "number"
      },
      "y2": {
        "title": "y₂",
        "description": "The y coordinate of the second corner.",
        "type": "number"
      },
      "x3": {
        "title": "x₃",
        "description": "The x coordinate of the third corner.",
        "type": "number"
      },
      "y3": {
        "title": "y₃",
        "description": "The y coordinate of the third corner.",
        "type": "number"
      }
    }
  },
  "outputs": {
    "area": {
      "label": "Area",
      "description": "The area inside the triangle, in square units.",
      "format": "number"
    },
    "perimeter": {
      "label": "Perimeter",
      "description": "The sum of the three sides (not with base and height).",
      "format": "number"
    },
    "sideA": {
      "label": "Side a",
      "description": "The length of side a.",
      "format": "number"
    },
    "sideB": {
      "label": "Side b",
      "description": "The length of side b.",
      "format": "number"
    },
    "sideC": {
      "label": "Side c",
      "description": "The length of side c.",
      "format": "number"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "method": "sss",
      "base": 10,
      "height": 8,
      "a": 5,
      "b": 6,
      "c": 7,
      "C": 1.0471975511965976,
      "A": 0.7853981633974483,
      "B": 1.0471975511965976,
      "x1": 0,
      "y1": 0,
      "x2": 4,
      "y2": 0,
      "x3": 0,
      "y3": 3
    },
    "outputs": {
      "area": 14.696938456699069,
      "perimeter": 18,
      "sideA": 5,
      "sideB": 6,
      "sideC": 7
    },
    "text": "The triangle has an area of 14.696938."
  },
  "examples": [
    {
      "given": {
        "method": "bh",
        "base": 10,
        "height": 8
      },
      "expect": {
        "area": 40
      },
      "source": "OpenStax, Prealgebra 2e, §9.4, area of a triangle (https://openstax.org/books/prealgebra-2e/pages/9-4-use-properties-of-rectangles-triangles-and-trapezoids); hand calculation in content.mdx: ½ × 10 × 8 = 40 (OpenStax Prealgebra 2e §9.4)"
    },
    {
      "given": {
        "method": "sss",
        "a": 5,
        "b": 6,
        "c": 7
      },
      "expect": {
        "area": 14.696938456699069,
        "perimeter": 18
      },
      "source": "hand calculation in content.mdx: Heron, s = 9, √(9 × 4 × 3 × 2) = 6√6; Python 3: 6*math.sqrt(6)"
    },
    {
      "given": {
        "method": "sas",
        "a": 5,
        "b": 6,
        "C": 1.0471975511965976
      },
      "expect": {
        "area": 12.99038105676658,
        "sideC": 5.5677643628300215
      },
      "source": "hand calculation in content.mdx: ½ × 5 × 6 × sin 60° = 15√3/2; c = √(25 + 36 − 30) = √31; Python 3: 7.5*math.sqrt(3), math.sqrt(31)"
    },
    {
      "given": {
        "method": "asa",
        "A": 0.7853981633974483,
        "B": 1.0471975511965976,
        "c": 7
      },
      "expect": {
        "area": 15.532377607281253
      },
      "source": "hand calculation in content.mdx: C = 75°, area = c² sin A sin B ÷ (2 sin C); mpmath (progress log)"
    },
    {
      "given": {
        "method": "points",
        "x1": 0,
        "y1": 0,
        "x2": 4,
        "y2": 0,
        "x3": 0,
        "y3": 3
      },
      "expect": {
        "area": 6,
        "perimeter": 12,
        "sideA": 5
      },
      "source": "hand calculation in content.mdx: ½ |4 × 3 − 0 × 0| = 6; sides 5, 3, 4"
    },
    {
      "given": {
        "method": "points",
        "x1": 0.1,
        "y1": 0.2,
        "x2": 0.4,
        "y2": 0.2,
        "x3": 0.1,
        "y3": 0.6
      },
      "expect": {
        "area": 0.06
      },
      "source": "hand calculation in content.mdx: exact decimals, ½ |0.3 × 0.4 − 0 × 0| = 0.06"
    }
  ],
  "sources": [
    "OpenStax, Prealgebra 2e, §9.4 Use Properties of Rectangles, Triangles, and Trapezoids (A = ½bh). https://openstax.org/books/prealgebra-2e/pages/9-4-use-properties-of-rectangles-triangles-and-trapezoids",
    "OpenStax, Algebra and Trigonometry 2e, §10.1 Non-right Triangles: Law of Sines (area = ½ab sin C) and §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",
    "W. Kahan, \"Miscalculating Area and Angles of a Needle-like Triangle\" (2014). https://people.eecs.berkeley.edu/~wkahan/Triangle.pdf",
    "Weisstein, Eric W. \"Triangle Area\", MathWorld (area from vertex coordinates). https://mathworld.wolfram.com/TriangleArea.html"
  ],
  "related": [
    "triangle",
    "right-triangle",
    "area",
    "law-of-cosines"
  ],
  "changelog": []
}
