Day: December 13, 2024

Equation of a hyperplane, and shortest distance between two hyperplanes.

December 13, 2024 math and physics play No comments , , , , , , ,

[Click here for a PDF version of this post]

Scalar equation for a hyperplane.

In our last post, we found, in a round about way, that

Theorem 1.1:

The equation of a \(\mathbb{R}^N\) hyperplane, with distance \( d \) from the origin, and normal \( \mathbf{\hat{n}} \) is
\begin{equation*}
\Bx \cdot \mathbf{\hat{n}} = d.
\end{equation*}

Start proof:

Let \( \beta = \setlr{ \mathbf{\hat{f}}_1, \cdots \mathbf{\hat{f}}_{N-1} } \) be an orthonormal basis for the hyperplane normal to \( \mathbf{\hat{n}} \), and \( \Bd = d \mathbf{\hat{n}} \) be the vector in that hyperplane, closest to the origin, as illustrated in fig. 1.

 

fig 1. R^3 plane with normal n-cap

The hyperplane \( d \) distant from the origin with normal \( \mathbf{\hat{n}} \) has the parametric representation
\begin{equation}\label{eqn:hyperplaneGeometry:40}
\Bx(a_1, \cdots, a_{N-1}) = d \mathbf{\hat{n}} + \sum_{i = 1}^{N-1} a_i \mathbf{\hat{f}}_i.
\end{equation}
Equivalently, suppressing the parameterization, with \( \Bx = \Bx(a_1, \cdots, a_{N-1}) \), representing any vector in that hyperplane, by dotting with \( \mathbf{\hat{n}} \), we have
\begin{equation}\label{eqn:hyperplaneGeometry:60}
\Bx \cdot \mathbf{\hat{n}} = d \mathbf{\hat{n}} \cdot \mathbf{\hat{n}},
\end{equation}
where all the \( \mathbf{\hat{f}}_i \cdot \mathbf{\hat{n}} \) dot products are zero by construction. Since \( \mathbf{\hat{n}} \cdot \mathbf{\hat{n}} = 0 \), the proof is complete.

End proof.

Incidentally, observe we can also write the hyperplane equation in dual form, as
\begin{equation}\label{eqn:hyperplaneGeometry:220}
\Bx \wedge (\mathbf{\hat{n}} I) = d I,
\end{equation}
where \( I \) is an \(\mathbb{R}^N\) pseudoscalar (such as \( I = \mathbf{\hat{n}} \mathbf{\hat{f}}_1 \cdots \mathbf{\hat{f}}_{N-1} \)).

Our previous parallel plane separation problem.

The standard \(\mathbb{R}^3\) scalar form for an equation of a plane is
\begin{equation}\label{eqn:hyperplaneGeometry:80}
a x + b y + c z = d,
\end{equation}
where \( d \) looses it’s geometrical meaning. If we form \( \Bn = (a,b,c) \), then we can rewrite this as
\begin{equation}\label{eqn:hyperplaneGeometry:100}
\Bx \cdot \Bn = d,
\end{equation}
for this representation of an equation of a plane, we see that \( d/\Norm{\Bn} \) is the shortest distance from the origin to the plane. This means that if we have a pair of parallel plane equations
\begin{equation}\label{eqn:hyperplaneGeometry:120}
\begin{aligned}
\Bx \cdot \Bn &= d_1 \\
\Bx \cdot \Bn &= d_2,
\end{aligned}
\end{equation}
then the distance between those planes, by inspection, is
\begin{equation}\label{eqn:hyperplaneGeometry:140}
\Abs{ \frac{d_2}{\Norm{\Bn}} – \frac{d_1}{\Norm{\Bn}} },
\end{equation}
which reduces to just \( \Abs{d_2 – d_1} \) if \( \Bn \) is a unit normal for the plane. In our previous post, the problem to solve was to find the shortest distance between the parallel planes given by
\begin{equation}\label{eqn:hyperplaneGeometry:160}
\begin{aligned}
x – y + 2 z &= -3 \\
3 x – 3 y + 6 z &= 1.
\end{aligned}
\end{equation}
The more natural geometrical form for these plane equations is
\begin{equation}\label{eqn:hyperplaneGeometry:180}
\begin{aligned}
\Bx \cdot \mathbf{\hat{n}} &= -\frac{3}{\sqrt{6}} \\
\Bx \cdot \mathbf{\hat{n}} &= \inv{3 \sqrt{6}},
\end{aligned}
\end{equation}
where \( \mathbf{\hat{n}} = (1,-1,2)/\sqrt{6} \), as illustrated in fig. 2.

fig. 2. The two planes.

 

Given that representation, we can find the distance between the planes just by taking the absolute difference of the respective distances to the origin
\begin{equation}\label{eqn:hyperplaneGeometry:200}
\begin{aligned}
\Abs{ -\frac{3}{\sqrt{6}} – \inv{3 \sqrt{6}} }
&= \frac{\sqrt{6}}{6} \lr{ 3 + \inv{3} } \\
&= \frac{10}{18} \sqrt{6} \\
&= \frac{5}{9} \sqrt{6}.
\end{aligned}
\end{equation}

Shortest distance between two parallel planes.

December 13, 2024 math and physics play No comments , , ,

[Click here for a PDF version of this post]

The problem.

Helping Karl with his linear algebra exam prep, he asked me about this problem

Problem:

Find the shortest distance between the two parallel planes, \( P_1 \), and \( P_2 \), with respective equations:
\begin{equation*}
\begin{aligned}
x – y + 2 z &= -3 \\
3 x – 3 y + 6 z &= 1.
\end{aligned}
\end{equation*}

A numerical way to tackle the problem.

A fairly straightforward way to tackle this problem is illustrated in the sketch of fig. 1. If we can find a point in the first plane, we can follow the normal to the plane to the next, and compute the length of that connecting vector.

fig. 1. Distance between two planes.

fig. 1. Distance between two planes.

For this problem, let
\begin{equation}\label{eqn:distanceBetweenPlanes:20}
\Bn = (1,-1,2),
\end{equation}
and rescale the two plane equations to use the same normal. That is
\begin{equation}\label{eqn:distanceBetweenPlanes:40}
\begin{aligned}
\Bx_1 \cdot \Bn &= -3 \\
\Bx_2 \cdot \Bn &= \inv{3},
\end{aligned}
\end{equation}
where \( \Bx_1 \) are vectors in the first plane, and \( \Bx_2 \) are vectors in the second plane. Finding a vector in one of the planes isn’t hard. Suppose, for example, that \( \Bx_0 = (\alpha, \beta, \gamma) \) is a vector in the first plane, then
\begin{equation}\label{eqn:distanceBetweenPlanes:60}
\alpha – \beta + 2 \gamma = -3.
\end{equation}
One solution is \( \alpha = -3, \beta = 0, \gamma = 0 \), or \( \Bx_0 = (-3, 0, 0) \). We can follow the normal from that point to the closest point in the second plane by forming
\begin{equation}\label{eqn:distanceBetweenPlanes:80}
\By_0 = \Bx_0 + k \Bn,
\end{equation}
where \( k \) is to be determined. If \( \By_0 \) is a point in the second plane, we must have
\begin{equation}\label{eqn:distanceBetweenPlanes:100}
\begin{aligned}
\inv{3}
&=
\By_0 \cdot \Bn \\
&=
\lr{ \Bx_0 + k \Bn } \cdot \Bn \\
&=
(-3, 0, 0 ) \cdot (1,-1,2) + k (1,-1,2) \cdot (1,-1,2) \\
&=
-3 + 6 k,
\end{aligned}
\end{equation}
or
\begin{equation}\label{eqn:distanceBetweenPlanes:120}
k = \frac{10}{18} = \frac{5}{9}.
\end{equation}
This means the point in plane two closest to \( \Bx_0 = (-3,0,0) \) is
\begin{equation}\label{eqn:distanceBetweenPlanes:140}
\begin{aligned}
\By_0
&= (-3, 0, 0 ) + \frac{5}{9} (1,-1,2) \\
&= \inv{9} (-27 + 5, -5, 10) \\
&= \inv{9} (-22, -5, 10),
\end{aligned}
\end{equation}
and the vector distance between the planes is
\begin{equation}\label{eqn:distanceBetweenPlanes:160}
\begin{aligned}
\By_0 – \Bx_0
&= \inv{9} (-22, -5, 10) – (-3, 0, 0 ) \\
&= \inv{9} (-22 + 27, -5, 10) \\
&= \inv{9} (5, -5, 10).
\end{aligned}
\end{equation}
This vector’s length is \( \sqrt{150}/9 = (5/9) \sqrt{6} \), which is the shortest distance between the planes.

A symbolic approach.

Generally, we get more clarity if we avoid plugging in numbers until the very end, so let’s try a generalization of this problem.

Problem:

Find the shortest distance between the two parallel planes, \( P_1 \), and \( P_2 \), with respective equations:
\begin{equation*}
\begin{aligned}
\Bx_1 \cdot \Bn_1 &= d_1 \\
\Bx_2 \cdot \Bn_2 &= d_2.
\end{aligned}
\end{equation*}

We can use the same approach, but first, let’s rescale the two normals. Let
\begin{equation}\label{eqn:distanceBetweenPlanes:180}
\Bn_2 = t \Bn_1,
\end{equation}
or
\begin{equation}\label{eqn:distanceBetweenPlanes:200}
\Bn_1 \cdot \Bn_2 = t \Bn_1^2,
\end{equation}
so
\begin{equation}\label{eqn:distanceBetweenPlanes:220}
\Bn_2 = \frac{\Bn_1 \cdot \Bn_2}{\Bn_1^2} \Bn_1,
\end{equation}
which means that our plane equations are
\begin{equation}\label{eqn:distanceBetweenPlanes:240}
\begin{aligned}
\Bx_1 \cdot \Bn_1 &= d_1 \\
\Bx_2 \cdot \Bn_1 &= \frac{\Bn_1^2}{\Bn_1 \cdot \Bn_2} d_2,
\end{aligned}
\end{equation}
We can further streamline our plane equation representation, setting \( \ncap = \Bn_1/\Norm{\Bn_1} \), which gives us
\begin{equation}\label{eqn:distanceBetweenPlanes:260}
\begin{aligned}
\Bx_1 \cdot \ncap &= \frac{d_1}{\Norm{\Bn_1}} \\
\Bx_2 \cdot \ncap &= \frac{d_2}{\ncap \cdot \Bn_2}.
\end{aligned}
\end{equation}

This time, let’s assume that we can find a point \( \Bx_0 \) in the first plane, but not actually try to find it. We can still follow the normal to the second plane from that point
\begin{equation}\label{eqn:distanceBetweenPlanes:280}
\By_0 = \Bx_0 + k \ncap,
\end{equation}
but since we only care about the vector distance between the planes, we seek
\begin{equation}\label{eqn:distanceBetweenPlanes:300}
\By_0 -\Bx_0 = k \ncap.
\end{equation}
Now, the constant \( k \), once we find it, is exactly the distance between the planes that we seek. Plugging \( \By_0 \) into the \( P_2 \) equation, we find
\begin{equation}\label{eqn:distanceBetweenPlanes:320}
\begin{aligned}
\frac{d_2}{\ncap \cdot \Bn_2}
&=
\lr{ \Bx_0 + k \ncap } \cdot \ncap \\
&=
\Bx_0 \cdot \ncap + k \\
&=
\frac{d_1}{\Norm{\Bn_1}} + k,
\end{aligned}
\end{equation}
or
\begin{equation}\label{eqn:distanceBetweenPlanes:340}
\boxed{
\Abs{k} = \Norm{\By_0 – \Bx_0} = \Abs{ \frac{d_2}{\ncap \cdot \Bn_2} – \frac{d_1}{\ncap \cdot \Bn_1} }.
}
\end{equation}
If \( \Bn_2 = \Bn_1 = \Bn \), then we have
\begin{equation}\label{eqn:distanceBetweenPlanes:360}
\begin{aligned}
\Norm{\By_0 – \Bx_0} &=
\Abs{
\frac{d_2}{\Bn_1^2/\Norm{\Bn_1}} – \frac{d_1}{\Norm{\Bn_1}}
} \\
&=
\frac{\Abs{d_2 – d_1}}{\Norm{\Bn}},
\end{aligned}
\end{equation}
and if \( \Bn \) is a unit normal, this further reduces to just \( \Abs{d_2 – d_1} \).

Let’s try this for the specific problem originally given. We have \( \Bn_1 = \Bn_2 \), so the distance between the planes is
\begin{equation}\label{eqn:distanceBetweenPlanes:380}
\begin{aligned}
\Norm{\By_0 – \Bx_0}
&= \frac{\Abs{1/3 + 3}}{\sqrt{6}} \\
&= \frac{10}{3 \times 6} \sqrt{6} \\
&= \frac{5}{9} \sqrt{6},
\end{aligned}
\end{equation}
as previously calculated.