Tetrahedral analog of the Pythagorean theorem

Tetrahedron has four triangular faces. Suppose three of those faces come together like the vertices of a cube, each perpendicular to the other. let A1, A2And A3 Find the area of ​​three triangles meeting at this corner A0 Let be the area of ​​the remaining face, which is opposite the right corner.

De Guia’s theorem, published in 1783, states

A0²= A1²+ A2²+ A3².

We will illustrate De Gua’s theorem using Python.

from numpy import *

def area(p1, p2, p3):
    return 0.5*abs(linalg.norm(cross(p1 - p3, p2 - p3)))

p0 = array([ 0, 0,  0])
p1 = array([11, 0,  0])
p2 = array([ 0, 3,  0])
p3 = array([ 0, 0, 25])

A0 = area(p1, p2, p3)
A1 = area(p0, p2, p3)
A2 = area(p0, p1, p3)
A3 = area(p0, p1, p2)

print(A0**2 - A1**2 - A2**2 - A3**2)

As expected, it prints 0.

higher dimensions

A natural question is whether De Guia’s theorem generalizes to higher dimensions, and indeed it does.

Let’s say you have a 4-simplex where one corner fits into the corner of a hypercube. The 4-simplex has 5 vertices. If you omit any vertex, the remaining 4 points determine a tetrahedron. let V0 Let be the volume of the tetrahedron formed by excluding the vertices at the vertices of the hypercube, and let V1, V2, V3And V4 Let be the volume of the tetrahedra formed by collapsing every other vertex. Then

V0²= V1²+ V2²+ V3²+ V4².

You can equally extend the theorem to higher dimensions.

Let’s describe the theorem for the 4-simplex in Python. The volume of a tetrahedron can be calculated as

V = date(Yes,1/2/6

Where? Yes Gram matrix is ​​calculated in the code below.

def volume(p1, p2, p3, p4):
    u = p1 - p4
    v = p2 - p4
    w = p3 - p4

    # construct the Gram matrix
    G = array( [
            [dot(u, u), dot(u, v), dot(u, w)],
            [dot(v, u), dot(v, v), dot(v, w)],
            [dot(w, u), dot(w, v), dot(w, w)] ])

    return sqrt(linalg.det(G))/6

p0 = array([ 0, 0,  0, 0])
p1 = array([11, 0,  0, 0])
p2 = array([ 0, 3,  0, 0])
p3 = array([ 0, 0, 25, 0])
p4 = array([ 0, 0,  0, 7])

V0 = volume(p1, p2, p3, p4)
V1 = volume(p0, p2, p3, p4)
V2 = volume(p0, p1, p3, p4)
V3 = volume(p0, p1, p2, p4)
V4 = volume(p0, p1, p2, p3)

print(V0**2 - V1**2 - V2**2 - V3**2 - V4**2)

This prints -9.458744898438454e-11. The result is 0, the limits of floating point arithmetic.

numerical analysis

Floating point arithmetic is typically accurate to 15 decimal places. Why is the above numerical error relatively large? Loss of precision is the usual suspect: subtracting nearly identical numbers. we have

V0 = 130978.7777777778

And

V1**2 + V2**2 + V3**2 + V4**2 = 130978.7777777779

Both results are correct up to 16 decimal places, but when we subtract them we lose all precision.



Leave a Comment