Function Repository Resource:

RightTriangleQ

Source Notebook

Determine whether a list of side lengths can form a right triangle

Contributed by: Wolfram|Alpha Math Team

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

determines whether the side lengths a,b and c represent a right triangle.

ResourceFunction["RightTriangleQ"][tri]

determines whether the triangle tri represents a right triangle.

Details and Options

ResourceFunction["RightTriangleQ"] supports Triangle input expressions.

Examples

Basic Examples (2) 

The set of lengths {3, 4, 5} forms a right triangle:

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

{2, 3, 4} does not form a right triangle:

In[2]:=
ResourceFunction["RightTriangleQ"][{2, 3, 4}]
Out[2]=

Scope (2) 

RightTriangleQ accepts triangle specifications:

In[3]:=
ResourceFunction["RightTriangleQ"][SSSTriangle[3, 4, 5]]
Out[3]=

RightTriangleQ applies to noninteger numbers:

In[4]:=
ResourceFunction["RightTriangleQ"][{Sqrt[2], Sqrt[3], Sqrt[5]}]
Out[4]=
In[5]:=
ResourceFunction["RightTriangleQ"][
 Triangle[{{0, 0}, {1, 0}, {0, Sqrt[3]}}]]
Out[5]=

Properties and Relations (2) 

To determine whether the given ordering of integers forms a Pythagorean triple, use PythagoreanTripleQ:

In[6]:=
ResourceFunction["PythagoreanTripleQ"][{3, 4, 5}]
Out[6]=
In[7]:=
ResourceFunction["RightTriangleQ"][{3, 4, 5}]
Out[7]=

Note that RightTriangleQ accepts any ordering of the edge lengths when determining if a right triangle can be formed from the edges, while a Pythagorean triple must be ordered:

In[8]:=
ResourceFunction["RightTriangleQ"][{5, 4, 3}]
Out[8]=
In[9]:=
ResourceFunction["PythagoreanTripleQ"][{5, 4, 3}]
Out[9]=

Publisher

Wolfram|Alpha Math Team

Version History

  • 2.0.0 – 23 March 2023
  • 1.0.0 – 18 September 2020

Related Resources

Author Notes

To view the full source code for RightTriangleQ, run the following code:

In[1]:=
FileNameJoin[
  ReplacePart[
   FileNameSplit[FindFile["ResourceFunctionHelpers`"]], -1 -> "PythagoreanTripleQ.wl"]] // SystemOpen

License Information