For any triangle with side lengths , the area can be found using the following formula:
where the semi-perimeter .
Using basic Trigonometry, we have which simplifies to
The Law of Cosines states that in triangle , , which can be written as . Thus,
Now, we can simplify:
Isosceles Triangle Simplification
for all triangles
for all isosceles triangles
Square root simplification/modification
From We can "take out" the in each , then we have Using the difference of squares on the first two and last two factors, we get and using the difference of squares again, we get From this equation (although seemingly not symmetrical), it is much easier to calculate the area of a certain triangle with side lengths with quantities with square roots. One can remember this formula by noticing that when finding the cosine of an angle in a triangle, the formula is and the two terms in the formula are just the denominator and numerator of the fraction for , only they're squared. This can also serve as a reason for why the area is never imaginary. This is equivalent of ending at step in the proof and distributing.
Replacing as , the area simplifies down to , or , or , another common area formula for the triangle.
Let's say that you have a right triangle with the sides , , and . Your semi- perimeter would be since ÷ is . Then you have , , . The square root of is . The area of your triangle is .
In general, it is a good advice not to use Heron's formula in computer programs whenever we can avoid it. For example, whenever vertex coordinates are known, vector product is a much better alternative. Main reasons:
- Computing the square root is much slower than multiplication.
- For triangles with area close to zero Heron's formula computed using floating point variables suffers from precision problems.