Equation of a plane passing through 3 points It should be simple, but I'm having trouble.
The three points are
$$A(1,-2,1)\qquad B(4,-2,-2)\qquad C(4,1,4)$$
The plane I get is
$$x+2y+z+6=0$$
but it obviously does not pass through the three points $A,B,C$.
 A: Here's one way to get the requisite plane:


*

*Get two different vectors which are in the plane, such as $B-A=(3,0,-3)$ and $C-A=(3,3,3)$.

*Compute the cross product of the two obtained vectors: $(B-A)×(C-A)=(9,-18,9)$. This is the normal vector of the plane, so we can divide it by 9 and get $(1,-2,1)$.

*The equation of the plane is thus $x-2y+z+k=0$. To get $k$, substitute any point and solve; we get $k=-6$.


The final equation of the plane is $x-2y+z-6=0$.
A: You’re looking for an equation of the form $ax+by+cz+d=0$. Plugging the coordinates of the known points into this generic equation gives you the following system of linear equations: $$\begin{align} a-2b+c+d&=0 \\ 4a-2b-2c+d&=0 \\ 4a+b+4c+d&=0.\end{align}$$ Solve this system for the unknown coefficients $a$, $b$, $c$ and $d$. The solution won’t be unique, but if all goes well (you haven’t made a mistake and the points aren’t colinear) the solution space will be one-dimensional. That’s to be expected since you can multiply the equation of a plane by any nonzero constant to get another equation for the same plane.  
The above system can be written as the matrix equation $$\begin{bmatrix}1&-2&1&1\\4&-2&-2&1\\4&1&4&1\end{bmatrix} \begin{bmatrix}a\\b\\c\\d\end{bmatrix} = 0$$ from which it’s evident that the coefficients of the equation of the plane are the components of any nonzero element of the null space of the matrix on the left. The first three columns are just the $x$-, $y$- and $z$-coordinates of the three points, therefore one can find the equation of the plane through three noncolinear points by computing the null space of $$\begin{bmatrix}x_1&y_1&z_1&1\\x_2&y_2&z_2&1\\x_3&y_3&z_3&1\end{bmatrix}.$$ In fact, it’s possible to do better and write down an equation of the plane directly. Every other point $(x,y,z)$ on the plane also generates a linear equation in the coefficients of the plane equation. In order to add it to the above system without reducing the dimension of the solution set, it must be dependent on the other equations, i.e., it must be a linear combination of the other three. This means that for any point $(x,y,z)$ on the plane, the rows of $$A = \begin{bmatrix}x&y&z&1\\x_1&y_1&z_1&1\\x_2&y_2&z_2&1\\x_3&y_3&z_3&1\end{bmatrix}$$ must be linearly dependent, but that means that $\det A=0$ is an equation of the plane. Applying this idea to the three points in your problem produces the equation $9x-18y+9z-54=0$, which becomes $x-2y+z-6=0$ after eliminating the common factor of $9$. This method is applicable to a wide variety of curves and surfaces.
