Function Repository Resource:

HeronFormula

Source Notebook

Compute the area of a triangle from the edge lengths

Contributed by: Ed Pegg Jr

ResourceFunction["HeronFormula"][{a,b,c}]

gives the area of the triangle with edge lengths {a,b,c}.

Details

Heron's formula is also known as Hero's formula.

Examples

Basic Examples (2) 

A 3-4-5 right triangle has area 6:

In[1]:=
ResourceFunction["HeronFormula"][{3, 4, 5}]
Out[1]=

A 13-14-15 triangle has area 84:

In[2]:=
ResourceFunction["HeronFormula"][{13, 14, 15}]
Out[2]=

Scope (2) 

HeronFormula works for inexact side lengths:

In[3]:=
ResourceFunction["HeronFormula"][{1.*^4, 5000.000001, 15000.}]
Out[3]=

HeronFormula works for symbolic arguments:

In[4]:=
ResourceFunction["HeronFormula"][{a, b, c}]
Out[4]=

Properties and Relations (2) 

Side lengths corresponding to a degenerate triangle will give a zero result:

In[5]:=
ResourceFunction["HeronFormula"][{3, 4, 7}]
Out[5]=

If the triangle inequality is not satisfied, HeronFormula remains unevaluated:

In[6]:=
ResourceFunction["HeronFormula"][{3, 4, 8}]
Out[6]=
In[7]:=
ResourceFunction["TriangleEdgesQ"][{3, 4, 8}]
Out[7]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 2.0.0 – 31 August 2021
  • 1.0.0 – 25 January 2019

Source Metadata

Related Resources

License Information