Halve the perimeter, then multiply s by s minus each side and take the root. For 3, 4, 5: s = 6, and √(6×3×2×1) = √36 = 6. No angle is needed and no height is needed — three lengths are enough to fix an area completely.
How the formula works
Three side lengths fix a triangle completely, so they must fix its area too. Heron’s formula is that area written down.
Take s = (a + b + c) ÷ 2, the semiperimeter. Then the area is √(s(s−a)(s−b)(s−c)).
Each of s−a, s−b and s−c is positive exactly when the three lengths can close into a triangle. If one of them is negative, the product goes negative and the root has no real value — the arithmetic refusing for the same reason the geometry does.
It generalises: Brahmagupta’s formula does the same for a cyclic quadrilateral, and reduces to Heron’s when one side shrinks to zero.
Why the order matters
Algebraically there is one formula. Numerically there are two, and they do not give the same answer on a thin triangle.
Take a = 100000, b = 99999.99999979, c = 0.00001. Here s−a and s−c are tiny differences between large numbers, and subtracting them first throws away most of the significant digits before anything is multiplied. The textbook form returns an area with about ten correct digits out of sixteen; on more extreme needles it returns zero, or NaN.
Kahan’s rearrangement sorts the sides so a ≥ b ≥ c and groups the terms as ¼√((a+(b+c))(c−(a−b))(c+(a−b))(a+(b−c))). Every subtraction is now between quantities of comparable size, and no digits are lost.
The parentheses are load-bearing. Evaluating the same expression in a different order reintroduces the problem, which is why the paper is careful about them and why this page follows it.
Worth noting what cannot be shown here: the textbook example uses a third side of 2.9 × 10⁻¹⁰, and adding that to 99999.99999979 in double precision rounds it away entirely — the sides then fail the triangle inequality before any area is computed. The example on this page is the smallest one that survives being typed in.
The degenerate case
Sides of 1, 2 and 3 give an area of exactly zero, and that is the correct answer rather than a failure.
1 + 2 = 3 exactly, so the two shorter sides just reach the end of the longest and the shape is a straight line. It is on the boundary of the triangle inequality: not a violation, but not a triangle with any interior either.
Go one step further — 1, 2 and 5 — and the sides cannot meet at all. The formula would ask for the root of a negative number, and the page refuses with the arithmetic that shows why.
Degenerate cases are worth handling deliberately because measured data produces them. Three surveyed distances that are very nearly collinear will land here, and returning NaN would be less useful than returning zero and saying so.
Heights from the area
Once you have the area, every height follows without any more geometry.
Area = ½ × base × height, so height = 2 × area ÷ base. Do that for each side in turn and you have all three altitudes.
This is genuinely useful: heights are awkward to measure and easy to compute. It is also why the precision of the area matters more than it looks — every height inherits whatever error the area has.
The inradius comes from the same place: r = area ÷ s. And the circumradius is abc ÷ (4 × area).
Where it is used
Surveying. A plot measured by walking its edges gives three lengths and no angles. Heron turns them into an area directly.
Triangulated shapes. Any polygon can be cut into triangles, and the total area is the sum. Computer graphics computes mesh areas exactly this way, millions of times a frame.
Coordinates. Given three points, the side lengths follow from Pythagoras and the area from Heron. The shoelace formula is usually quicker there, but Heron needs only distances, which is sometimes all you have.
Checking. An area computed as ½ab·sin C and again by Heron should agree. When they do not, one of the inputs is wrong.
Its history
Named for Hero of Alexandria, who proved it in his Metrica around 60 CE. The proof there is geometric and does not look much like the algebra.
Archimedes may have known it two centuries earlier — Arab commentators attribute it to him — and the Chinese Nine Chapters tradition arrived at an equivalent result independently.
The numerical difficulty is much more recent. It only appears once you compute in floating point, and Kahan’s note on it dates from 1986. Two thousand years of correct algebra, and a precision problem that is thirty-nine years old.
Sources and methodology
The formula is ancient and the numerical problem is documented; these are the references.
Method. The area is computed by sorting the sides and grouping the terms so that no step subtracts two nearly equal large numbers. The textbook form is computed separately and displayed beside it, with the disagreement reported when there is one — the point being to show the cost rather than assert it. The suite checks the stable form against ½ab·sin C, a completely different route, and separately checks that the textbook form really does fail on a needle. That engine is verified on every change against 76 hand-written assertions, including agreement with ½ab·sin C across four thousand generated triangles, and that the textbook form genuinely disagrees on a needle rather than the page merely claiming it would. The count and the per-case breakdown are published on the formula verification page.
Read the guide
The Triangle Calculator gives this area alongside every angle, height and radius, and handles the cases where you have angles rather than three sides.