# Heron's formula

In geometry, Heron's formula (or Hero's formula) gives the area of a triangle in terms of the three side lengths ⁠$a,$⁠ ⁠$b,$⁠ ⁠$c.$⁠ Letting ⁠$s$⁠ be the semiperimeter of the triangle, $s={\tfrac {1}{2}}(a+b+c),$ the area ⁠$A$⁠ is
$A={\sqrt {s(s-a)(s-b)(s-c)}}.$
It is named after first-century engineer Heron of Alexandria (or Hero) who proved it in his work Metrica, though it was probably known centuries earlier.

## Example

Area calculator :
| a | 3 |
| b | 4 |
| c | 5 |
| s | 6 |
| Area | 6.000 |
Let ⁠$\triangle ABC$⁠ be the triangle with sides ⁠$a=4$⁠, ⁠$b=13$⁠, and ⁠$c=15$⁠. This triangle's semiperimeter is $s={\tfrac {1}{2}}(a+b+c)=$${\tfrac {1}{2}}(4+13+15)=16$ therefore ⁠$s-a=12$⁠, ⁠$s-b=3$⁠, ⁠$s-c=1$⁠, and the area is ${\begin{aligned}A&={\textstyle {\sqrt {s(s-a)(s-b)(s-c)}}}\\[3mu]&={\textstyle {\sqrt {16\cdot 12\cdot 3\cdot 1{\vphantom}}}}}\\[3mu]&=24.\end{aligned}}$
In this example, the triangle's side lengths and area are integers, making it a Heronian triangle. However, Heron's formula works equally well when the side lengths are real numbers. As long as they obey the strict triangle inequality, they define a triangle in the Euclidean plane whose area is a positive real number.

## Alternate expressions

Heron's formula can also be written in terms of just the side lengths instead of using the semiperimeter, in several ways,
${\begin{aligned}A&={\tfrac {1}{4}}{\sqrt {(a+b+c)(-a+b+c)(a-b+c)(a+b-c)}}\\[6mu]&={\tfrac {1}{4}}{\sqrt {2(a^{2}b^{2}+a^{2}c^{2}+b^{2}c^{2})-(a^{4}+b^{4}+c^{4})}}\\[6mu]&={\tfrac {1}{4}}{\sqrt {(a^{2}+b^{2}+c^{2})^{2}-2(a^{4}+b^{4}+c^{4})}}\\[6mu]&={\tfrac {1}{4}}{\sqrt {4(a^{2}b^{2}+a^{2}c^{2}+b^{2}c^{2})-(a^{2}+b^{2}+c^{2})^{2}}}\\[6mu]&={\tfrac {1}{4}}{\sqrt {4a^{2}b^{2}-(a^{2}+b^{2}-c^{2})^{2}}}.\end{aligned}}$
After expansion, the expression under the square root is a quadratic polynomial of the squared side lengths ⁠$a^{2}$⁠, ⁠$b^{2}$⁠, ⁠$c^{2}$⁠.
The same relation can be expressed using the Cayley–Menger determinant,
$-16A^{2}={\begin{vmatrix}0&a^{2}&b^{2}&1\\a^{2}&0&c^{2}&1\\b^{2}&c^{2}&0&1\\1&1&1&0\end{vmatrix}}.$

## History

The formula is credited to Heron (or Hero) of Alexandria (fl. 60 AD), and a proof can be found in his book Metrica. Mathematical historian Thomas Heath suggested that Archimedes knew the formula over two centuries earlier, and since Metrica is a collection of the mathematical knowledge available in the ancient world, it is possible that the formula predates the reference given in that work.
A formula equivalent to Heron's was discovered by Chinese mathematician Qin Jiushao:
$A={\frac {1}{2}}{\sqrt {a^{2}c^{2}-\left({\frac {a^{2}+c^{2}-b^{2}}{2}}\right)^{2}}},$
published in Mathematical Treatise in Nine Sections (Qin Jiushao, 1247).

## Proofs

There are many ways to prove Heron's formula, for example using trigonometry as below, or the incenter and one excircle of the triangle, or as a special case of De Gua's theorem (for the particular case of acute triangles), or as a special case of Brahmagupta's formula (for the case of a degenerate cyclic quadrilateral).

### Trigonometric proof using the law of cosines

A modern proof, which uses algebra and is quite different from the one provided by Heron, follows. Let ⁠$a,$⁠ ⁠$b,$⁠ ⁠$c$⁠ be the sides of the triangle and ⁠$\alpha ,$⁠ ⁠$\beta ,$⁠ ⁠$\gamma$⁠ the angles opposite those sides. Applying the law of cosines we get
$\cos \gamma ={\frac {a^{2}+b^{2}-c^{2}}{2ab}}$
From this proof, we get the algebraic statement that
$\sin \gamma ={\sqrt {1-\cos ^{2}\gamma }}={\frac {\sqrt {4a^{2}b^{2}-(a^{2}+b^{2}-c^{2})^{2}}}{2ab}}.$
The altitude of the triangle on base ⁠$a$⁠ has length ⁠$b\sin \gamma$⁠, and it follows
${\begin{aligned}A&={\tfrac {1}{2}}({\mbox{base}})({\mbox{altitude}})\\[6mu]&={\tfrac {1}{2}}ab\sin \gamma \\[6mu]&={\frac {ab}{4ab}}{\sqrt {4a^{2}b^{2}-(a^{2}+b^{2}-c^{2})^{2}}}\\[6mu]&={\tfrac {1}{4}}{\sqrt {-a^{4}-b^{4}-c^{4}+2a^{2}b^{2}+2a^{2}c^{2}+2b^{2}c^{2}}}\\[6mu]&={\tfrac {1}{4}}{\sqrt {(a+b+c)(-a+b+c)(a-b+c)(a+b-c)}}\\[6mu]&={\sqrt {\left({\frac {a+b+c}{2}}\right)\left({\frac {-a+b+c}{2}}\right)\left({\frac {a-b+c}{2}}\right)\left({\frac {a+b-c}{2}}\right)}}\\[6mu]&={\sqrt {s(s-a)(s-b)(s-c)}}.\end{aligned}}$

### Algebraic proof using the Pythagorean theorem

The following proof is very similar to one given by Raifaizen. By the Pythagorean theorem we have $b^{2}=h^{2}+d^{2}$ and $a^{2}=h^{2}+(c-d)^{2}$ according to the figure at the right. Subtracting these yields $a^{2}-b^{2}=c^{2}-2cd.$ This equation allows us to express ⁠$d$⁠ in terms of the sides of the triangle: $d={\frac {-a^{2}+b^{2}+c^{2}}{2c}}.$ For the height of the triangle we have that $h^{2}=b^{2}-d^{2}.$ By replacing ⁠$d$⁠ with the formula given above and applying the difference of squares identity we get ${\begin{aligned}h^{2}&=b^{2}-\left({\frac {-a^{2}+b^{2}+c^{2}}{2c}}\right)^{2}\\&={\frac {(2bc-a^{2}+b^{2}+c^{2})(2bc+a^{2}-b^{2}-c^{2})}{4c^{2}}}\\&={\frac {{\big(b+c)^{2}-a^{2}{\big )}{\biga^{2}-(b-c)^{2}{\big )}}{4c^{2}}}\\&={\frac {(b+c-a)(b+c+a)(a+b-c)(a-b+c)}{4c^{2}}}\\&={\frac {2(s-a)\cdot 2s\cdot 2(s-c)\cdot 2(s-b)}{4c^{2}}}\\&={\frac {4s(s-a)(s-b)(s-c)}{c^{2}}}.\end{aligned}}$
We now apply this result to the formula that calculates the area of a triangle from its height: ${\begin{aligned}A&={\frac {ch}{2}}\\&={\sqrt {{\frac {c^{2}}{4}}\cdot {\frac {4s(s-a)(s-b)(s-c)}{c^{2}}}}}\\&={\sqrt {s(s-a)(s-b)(s-c)}}.\end{aligned}}$

### Trigonometric proof using the law of cotangents

If ⁠$r$⁠ is the radius of the incircle of the triangle, then the triangle can be broken into three triangles of equal altitude ⁠$r$⁠ and bases ⁠$a,$⁠ ⁠$b,$⁠ and ⁠$c.$⁠ Their combined area is $A={\tfrac {1}{2}}ar+{\tfrac {1}{2}}br+{\tfrac {1}{2}}cr=rs,$ where $s={\tfrac {1}{2}}(a+b+c)$ is the semiperimeter.
The triangle can alternately be broken into six triangles (in congruent pairs) of altitude ⁠$r$⁠ and bases ⁠$s-a,$⁠ ⁠$s-b,$⁠ and ⁠$s-c$⁠ of combined area (see law of cotangents) ${\begin{aligned}A&=r(s-a)+r(s-b)+r(s-c)\\[2mu]&=r^{2}\left({\frac {s-a}{r}}+{\frac {s-b}{r}}+{\frac {s-c}{r}}\right)\\[2mu]&=r^{2}\left(\cot {\frac {\alpha }{2}}+\cot {\frac {\beta }{2}}+\cot {\frac {\gamma }{2}}\right)\\[3mu]&=r^{2}\left(\cot {\frac {\alpha }{2}}\cot {\frac {\beta }{2}}\cot {\frac {\gamma }{2}}\right)\\[3mu]&=r^{2}\left({\frac {s-a}{r}}\cdot {\frac {s-b}{r}}\cdot {\frac {s-c}{r}}\right)\\[3mu]&={\frac {(s-a)(s-b)(s-c)}{r}}.\end{aligned}}$
The middle step above is cot⁡ α/2+cot⁡ β/2+cot⁡ γ/2={\textstyle \cot {\tfrac {\alpha }{2}}+\cot {\tfrac {\beta }{2}}+\cot {\tfrac {\gamma }{2}}=}$\cot {\tfrac {\alpha }{2}}\cot {\tfrac {\beta }{2}}\cot {\tfrac {\gamma }{2}},$ the triple cotangent identity, which applies because the sum of half-angles is α/2+β/2+γ/2=π/2.{\textstyle {\tfrac {\alpha }{2}}+{\tfrac {\beta }{2}}+{\tfrac {\gamma }{2}}={\tfrac {\pi }{2}}.}
Combining the two, we get $A^{2}=s(s-a)(s-b)(s-c),$ from which the result follows.

## Numerical stability

Heron's formula as given above is numerically unstable for triangles with a very small angle when using floating-point arithmetic. A stable alternative involves arranging the lengths of the sides so that $a\geq b\geq c$ and computing $A={\tfrac {1}{4}}{\sqrt {{\biga+(b+c){\big )}{\bigc-(a-b){\big )}{\bigc+(a-b){\big )}{\biga+(b-c){\big )}}}.$ The extra brackets indicate the order of operations required to achieve numerical stability in the evaluation.

## Similar triangle-area formulae

Three other formulae for the area of a general triangle have a similar structure as Heron's formula, expressed in terms of different variables.
First, if ⁠$m_{a},$⁠ ⁠$m_{b},$⁠ and ⁠$m_{c}$⁠ are the medians from sides ⁠$a,$⁠ ⁠$b,$⁠ and ⁠$c$⁠ respectively, and their semi-sum is $\sigma ={\tfrac {1}{2}}(m_{a}+m_{b}+m_{c}),$ then $A={\frac {4}{3}}{\sqrt {\sigma (\sigma -m_{a})(\sigma -m_{b})(\sigma -m_{c})}}.$
Next, if ⁠$h_{a}$⁠, ⁠$h_{b}$⁠, and ⁠$h_{c}$⁠ are the altitudes from sides ⁠$a,$⁠ ⁠$b,$⁠ and ⁠$c$⁠ respectively, and semi-sum of their reciprocals is $H={\tfrac {1}{2}}{\biglh_{a}^{-1}+h_{b}^{-1}+h_{c}^{-1}{\bigr )},$ then $A^{-1}=4{\sqrt {H{\biglH-h_{a}^{-1}{\bigr )}{\biglH-h_{b}^{-1}{\bigr )}{\biglH-h_{c}^{-1}{\bigr )}}}.$
Finally, if ⁠$\alpha ,$⁠ ⁠$\beta ,$⁠ and ⁠$\gamma$⁠ are the three angle measures of the triangle, and the semi-sum of their sines is $S={\tfrac {1}{2}}(\sin \alpha +\sin \beta +\sin \gamma ),$ then ${\begin{aligned}A&=D^{2}{\sqrt {S(S-\sin \alpha )(S-\sin \beta )(S-\sin \gamma )}}\\[5mu]&={\tfrac {1}{2}}D^{2}\sin \alpha \,\sin \beta \,\sin \gamma ,\end{aligned}}$
where ⁠$D$⁠ is the diameter of the circumcircle, $D=a/{\sin \alpha }=b/{\sin \beta }=c/{\sin \gamma }.$ This last formula coincides with the standard Heron formula when the circumcircle has unit diameter.

## Generalizations

Heron's formula is a special case of Brahmagupta's formula for the area of a cyclic quadrilateral. Heron's formula and Brahmagupta's formula are both special cases of Bretschneider's formula for the area of a quadrilateral. Heron's formula can be obtained from Brahmagupta's formula or Bretschneider's formula by setting one of the sides of the quadrilateral to zero.
Brahmagupta's formula gives the area ⁠$K$⁠ of a cyclic quadrilateral whose sides have lengths ⁠$a,$⁠ ⁠$b,$⁠ ⁠$c,$⁠ ⁠$d$⁠ as
$K={\sqrt {(s-a)(s-b)(s-c)(s-d)}}$
where $s={\tfrac {1}{2}}(a+b+c+d)$ is the semiperimeter.
Heron's formula is also a special case of the formula for the area of a trapezoid or trapezium based only on its sides. Heron's formula is obtained by setting the smaller parallel side to zero.
Expressing Heron's formula with a Cayley–Menger determinant in terms of the squares of the distances between the three given vertices, $A={\frac {1}{4}}{\sqrt {-{\begin{vmatrix}0&a^{2}&b^{2}&1\\a^{2}&0&c^{2}&1\\b^{2}&c^{2}&0&1\\1&1&1&0\end{vmatrix}}}}$ illustrates its similarity to Tartaglia's formula for the volume of a three-simplex.
Another generalization of Heron's formula to pentagons and hexagons inscribed in a circle was discovered by David P. Robbins.

### Degenerate and imaginary triangles

If one of three given lengths is equal to the sum of the other two, the three sides determine a degenerate triangle, a line segment with zero area. In this case, the semiperimeter will equal the longest side, causing Heron's formula to equal zero.
If one of three given lengths is greater than the sum of the other two, then they violate the triangle inequality and do not describe the sides of a Euclidean triangle. In this case, Heron's formula gives an imaginary result. For example if ⁠$a=3$⁠ and ⁠$b=c=1$⁠, then ⁠$\textstyle A={\tfrac {3{\sqrt {5}}}{4}}i$⁠. This can be interpreted using a triangle in the complex coordinate plane ⁠$\mathbb {C} ^{2}$⁠, where "area" can be a complex-valued quantity, or as a triangle lying in a pseudo-Euclidean plane with one space-like dimension and one time-like dimension.

### Volume of a tetrahedron

If ⁠$U,$⁠ ⁠$V,$⁠ ⁠$W,$⁠ ⁠$u,$⁠ ⁠$v,$⁠ ⁠$w$⁠ are lengths of edges of the tetrahedron (first three form a triangle; ⁠$u$⁠ opposite to ⁠$U$⁠ and so on), then ${\text{volume}}={\frac {\sqrt {\,(-a+b+c+d)\,(a-b+c+d)\,(a+b-c+d)\,(a+b+c-d)}}{192\,u\,v\,w}}$ where ${\begin{aligned}a&={\sqrt {xYZ}}\\b&={\sqrt {yZX}}\\c&={\sqrt {zXY}}\\d&={\sqrt {xyz}}\\X&=(w-U+v)\,(U+v+w)\\x&=(U-v+w)\,(v-w+U)\\Y&=(u-V+w)\,(V+w+u)\\y&=(V-w+u)\,(w-u+V)\\Z&=(v-W+u)\,(W+u+v)\\z&=(W-u+v)\,(u-v+W).\end{aligned}}$

### Spherical and hyperbolic geometry

L'Huilier's formula relates the area of a triangle in spherical geometry to its side lengths. For a spherical triangle with side lengths ⁠$a,$⁠ ⁠$b,$⁠ and ⁠$c$⁠, semiperimeter ⁠$s={\tfrac {1}{2}}(a+b+c)$⁠, and area ⁠$S$⁠, $\tan ^{2}{\frac {S}{4}}=\tan {\frac {s}{2}}\tan {\frac {s-a}{2}}\tan {\frac {s-b}{2}}\tan {\frac {s-c}{2}}$
For a triangle in hyperbolic geometry the analogous formula is $\tan ^{2}{\frac {S}{4}}=\tanh {\frac {s}{2}}\tanh {\frac {s-a}{2}}\tanh {\frac {s-b}{2}}\tanh {\frac {s-c}{2}}.$