05 Planes#
A hyperplane in n-dimensional space is a subspace that is one dimension less than the space itself. It’s an “n-1” dimensional subspace of an “n” dimensional space.
Here are some examples to illustrate this concept:
In 2-dimensional space (a plane): A hyperplane is a 1-dimensional line. For example, in a 2D Cartesian coordinate system, the line defined by the equation
y = 2x + 1
is a hyperplane.In 3-dimensional space: A hyperplane is a 2-dimensional plane. For example, in a 3D Cartesian coordinate system, the plane defined by the equation
2x + 3y - z = 5
is a hyperplane.In 4-dimensional space: A hyperplane is a 3-dimensional space. It’s harder to visualize, but it’s defined by an equation like
x + 2y + 3z - 4w = 7
.
In general, a hyperplane can be defined by a linear equation of the form:
where \(a_1, a_2, ..., a_n\) are the coefficients of the hyperplane, \(x_1, x_2, ..., x_n\) are the variables (or coordinates in the space), and \(b\) is a constant. The coefficients \(a_1, a_2, ..., a_n\) determine the orientation of the hyperplane in the space, and the constant \(b\) determines its offset from the origin.
Representations#
There are infinitely many alternative descriptions for the hyperplane P.
The equation of a hyperplane is not unique. Any scalar multiple of the normal vector and the offset will describe the same hyperplane.
If \(\mathbf{A}\) is the normal vector to the hyperplane and \(A_0\) is the offset, then for any non-zero scalar \(k\), the vector \(k\mathbf{A}\) and the offset \(kA_0\) will describe the same hyperplane.
So, for example, if \(\mathbf{A} = [1, 2, 3]\) and \(A_0 = 4\) describe a hyperplane, then \(2\mathbf{A} = [2, 4, 6]\) and \(2A_0 = 8\) will describe the same hyperplane. Similarly, \(0.5\mathbf{A} = [0.5, 1, 1.5]\) and \(0.5A_0 = 2\) will also describe the same hyperplane.
This is because scaling the normal vector and the offset by the same factor does not change the set of points \((x_1, x_2, ..., x_d)\) that satisfy the equation \(\mathbf{A} \cdot \mathbf{x} + A_0 = 0\).
Orthogonality Check#
To check if a vector \(\mathbf{x}\) is orthogonal to a hyperplane P characterized by a normal vector \(\mathbf{A}\) and an offset \(A_0\), you need to check the dot product between \(\mathbf{x}\) and \(\mathbf{A}\).
The dot product of two vectors \(\mathbf{a} = [a_1, a_2, ..., a_n]\) and \(\mathbf{b} = [b_1, b_2, ..., b_n]\) is calculated as:
If the dot product is zero, then \(\mathbf{x}\) is orthogonal to the hyperplane. This is because the dot product of two vectors is zero if and only if the vectors are orthogonal.
So, to check if \(\mathbf{x}\) is orthogonal to the hyperplane P, you would calculate:
If this equation holds, then \(\mathbf{x}\) is orthogonal to the hyperplane P.
dot_product = np.dot(A, x)
if dot_product == 0:
print("x is orthogonal to the hyperplane P")
else:
print("x is not orthogonal to the hyperplane P")
Signed Perpendicular Distance to Plane#
The signed distance \(d\) between a point or vector \(\mathbf{x} = [x_1, x_2, ..., x_n]\) and a hyperplane P characterized by a normal vector \(\mathbf{A} = [A_1, A_2, ..., A_n]\) and an offset \(A_0\) can be calculated using the following formula:
Here, \(\mathbf{A} \cdot \mathbf{x}\) is the dot product of \(\mathbf{A}\) and \(\mathbf{x}\), and \(\|\mathbf{A}\|\) is the Euclidean norm (or length) of \(\mathbf{A}\), calculated as \(\sqrt{A_1^2 + A_2^2 + ... + A_n^2}\).
The sign of the distance indicates which side of the hyperplane the point \(\mathbf{x}\) is on. If the distance is positive, \(\mathbf{x}\) is on the side of the hyperplane in the direction of the normal vector \(\mathbf{A}\). If the distance is negative, \(\mathbf{x}\) is on the opposite side. If the distance is zero, \(\mathbf{x}\) is on the hyperplane.
Orthogonal projection onto plane#
The orthogonal projection of a point \(\mathbf{v}\) onto a hyperplane P characterized by a normal vector \(\mathbf{A}\) and an offset \(A_0\) is given by the following formula:
Here, \(\mathbf{A} \cdot \mathbf{v}\) is the dot product of \(\mathbf{A}\) and \(\mathbf{v}\), and \(\|\mathbf{A}\|^2\) is the square of the Euclidean norm (or length) of \(\mathbf{A}\), calculated as \(A_1^2 + A_2^2 + ... + A_n^2\).
The vector \(\mathbf{p}\) is the orthogonal projection of \(\mathbf{v}\) onto the hyperplane P. It is the point on the hyperplane that is closest to \(\mathbf{v}\).
Question (signed perpendicular distance)#
Let P be the hyperplane consisting of the set of points x = [x1, x2] for which 3x1 + x2 -1 = 0. What is the signed perpendicular distance of point a = [-1, -1] from P?
Explanation
The signed perpendicular distance d
from a point a
to a hyperplane P
characterized by a normal vector A
and an offset A0
is given by the formula:
Here, A.a
is the dot product of A
and a
, and ||A||
is the Euclidean norm (or length) of A
.
In this case, the hyperplane P
is defined by the equation 3x1 + x2 - 1 = 0
, so the normal vector A
is [3, 1]
and the offset A0
is -1
. The point a
is [-1, -2]
.
The dot product A.a
is \(3*(-1) + 1*(-1) = -4\).
The Euclidean norm ||A||
is \(\sqrt{(3^2 + 1^2)} = \sqrt{(10)}\).
So, the signed perpendicular distance d
from a
to P
is \((-4 + (-1)) / \sqrt{10} = -5 / \sqrt{10}\).
This means that the point a
is approximately 1.26491 units away from the hyperplane P
, and it’s on the side of the hyperplane opposite to the direction of the normal vector A
.
Here is the Python code to calculate this:
import numpy as np
# Plane P is 3x1 + x2 -1 = 0
A = np.array([3, 1])
A0 = -1
# Point a = (-1, -1)
a = np.array([-1, -1])
d = (np.dot(A, a) + A0) / np.linalg.norm(A)
print(f'A.a + A0 : {np.dot(A, a) + A0}')
print(f'||A|| : {np.linalg.norm(A)}')
print(d)
A.a + A0 : -5
||A|| : 3.1622776601683795
-1.5811388300841895
Question (Distance from Origin)#
For the above question, what is the signed perpendicular distance of the origin
from P
?
Hint: The point a
is the origin [0, 0]
import numpy as np
# Plane P is 3x1 + x2 -1 = 0
A = np.array([3, 1])
A0 = -1
# Origin point a = [0, 0]
a = np.array([0, 0])
d = (np.dot(A, a) + A0) / np.linalg.norm(A)
print(f'A.a + A0 : {np.dot(A, a) + A0}')
print(f'||A|| : {np.linalg.norm(A)}')
print(d)
A.a + A0 : -1
||A|| : 3.1622776601683795
-0.31622776601683794
Question (Orthogonal Projection)#
The orthogonal projection p
of a point a
onto a hyperplane P
characterized by a normal vector A
and an offset A0
is given by the formula:
Here, A.a
is the dot product of A
and a
, and ||A||^2
is the square of the Euclidean norm (or length) of A
.
In this case, the hyperplane P
is defined by the equation 3x1 + x2 - 1 = 0
, so the normal vector A
is [3, 1]
and the offset A0
is -1
. The point a
is [-1, -2]
.
The dot product A.a
is \(3*(-1) + 1*(-1) = -4\).
The Euclidean norm ||A||
is \((\sqrt{(3^2 + 1^2)})^2 = (\sqrt{(10)})^2 = 10\).
So, the orthogonal projection p
of a
onto P
is
This means that the orthogonal projection of a
onto P
is the point [0.5, -0.5]
.
import numpy as np
A = np.array([3, 1])
A0 = -1
a = np.array([-1, -1])
p = a - ((np.dot(A, a) + A0) / np.linalg.norm(A)**2) * A
print(p)
[ 0.5 -0.5]
Question#
Consider a hyperplane in a d-dimensional space. If we project a point onto the plane, can we recover the original point from this projection?
No, we cannot recover the original point from its projection onto a hyperplane in a d-dimensional space.
The reason is that the projection operation is a lossy operation. When you project a point onto a hyperplane, you are essentially collapsing the point’s position along the direction perpendicular to the hyperplane down to the closest point on the hyperplane. This means that the information about how far the point was from the hyperplane along that direction is lost in the projection.
Therefore, given only the projected point, there is no way to determine exactly where the original point was. It could have been anywhere along the line perpendicular to the hyperplane that passes through the projected point.