# Solving system of 3 linear equations for 4 unknowns

Consider the following system of 3 linear equations and 4 unknowns, represented in matrix multiplication form as follows:

$$\begin{bmatrix}C_1&C_2&C_3&C_4\end{bmatrix}\begin{bmatrix} \cos(t) \\ \sin(t) \\ u \\ v \end{bmatrix}=C_0$$

where $C_i$ ($0\leq i\leq 4$) is a 3D column vector.

How can this system be solved for $u$, $v$ and $t$?

Edit:

Let $c=\cos(t)$. We have $\sin(t)=\pm\sqrt{1-c^2}$.

Here $C_i^2=\begin{bmatrix}c_{i,1}^2&c_{i,2}^2&c_{i,3}^2\end{bmatrix}^T$

$$(1-c^2)C_2^2=(C_0-cC_1-uC_3-vC_4)^2$$

$$C_2^2-C_0^2=c^2(C_1^2+C_2^2)+u^2C_3^2+v^2C_4^2-2cC_0C_1-2uC_0C_3-2vC_0C_4+2cuC_1C_3+2cvC_1C_4+2uvC_3C_4$$

And it stops here; anybody knows how to solve this?

Method 2:

Let $A=\begin{bmatrix}C_1&C_2&C_3&C_4\end{bmatrix}$ and $X=\begin{bmatrix}\cos(t)&\sin(t)&u&v\end{bmatrix}^T$.

The system becomes:

$$AX=C_0$$

Using the pseudo-inverse of $A$:

$$X=A^T(AA^T)^{-1}C_0$$

$$A^T=\begin{bmatrix}C_1^T\\C_2^T\\C_3^T\\C_4^T\end{bmatrix}\quad and\quad (AA^T)^{-1}=(C_1C_1^T+C_2C_2^T+C_3C_3^T+C_4C_4^T)^{-1}$$

$AA^T$ and $C_iC_i^T$ are symmetric 3-by-3 matrices.

However I don't know of a way to expand $(AA^T)^{-1}$ while keeping $C_i$ intact.

• You don't actually have "four unknowns", you have three: t, u, and v. These four equations are $C_1cos(t)= C_0$, $C_2sin(t)= C_0$, $C_2u= C_0$, and $C_4v= C_0$. The last two give $u= \frac{C_0}{C_3}$ and $v= \frac{C_0}{C_4}$, of course. To have $C_1cos(t)= C_0$ and $C_2 sin(t)= C_0$ you must have $\frac{C_2 sin(t)}{C_1 cos(t)}= 1$ or $tan(t)= \frac{C_1}{C_2}$. – user247327 Jun 9 '17 at 0:59

Let $c=\cos(t), \sin (t)= \pm \sqrt {1-c^2}$ and you have three equations in three unknowns. You have to solve it twice, once for each sign of $\sin(t)$ and getting rid of the square root may introduce extraneous solutions.

• Your suggestion didn't really solve the problem. After getting rid of the square root, the equation becomes more complex to solve. – R. 久蔵 Jun 9 '17 at 14:42

Suppose $v=0$, the system becomes:

$$\begin{bmatrix}C_1&C_2&C_3\end{bmatrix}\begin{bmatrix}\cos(t)\\\sin(t)\\u\end{bmatrix}=C_0$$

which can be solved using Cramer's rule.

I'm still searching for the general case.

Edit:

Here's what I came up with using Gaussian elimination.

The system is:

$$\begin{cases}\cos⁡(t)c_{11}+\sin⁡(t)c_{12}+uc_{13}+vc_{14}=d_1\\\cos⁡(t) c_{21}+\sin⁡(t)c_{22}+uc_{23}+vc_{24}=d_2\\\cos⁡(t)c_{31}+\sin⁡(t)c_{32}+uc_{33}+vc_{34}=d_3\end{cases}$$

The augmented matrix is:

$$\begin{bmatrix}c_{11}&c_{12}&c_{13}&c_{14}&d_1\\c_{21}&c_{22}&c_{23}&c_{24}&d_2\\c_{31}&c_{32}&c_{33}&c_{34}&d_3\end{bmatrix}$$

Applying $c_{14}L_2-c_{24}L_1→L_2$ and $c_{14}L_3-c_{34}L_1→L_3$ gives:

$$\begin{bmatrix}c_{11}&c_{12}&c_{13}&c_{14}&d_1\\c_{14}c_{21}-c_{24}c_{11}&c_{14}c_{22}-c_{24}c_{12}&c_{14}c_{23}-c_{24}c_{13}&0&c_{14}d_2-c_{24}d_1\\c_{14}c_{31}-c_{34}c_{11}&c_{14}c_{32}-c_{34}c_{12}&c_{14}c_{33}-c_{34}c_{13}&0&c_{14}d_3-c_{34}d_1\end{bmatrix}$$

And applying $(c_{14}c_{23}-c_{24}c_{13})L_3-(c_{14}c_{33}-c_{34}c_{13})L_2→L_3$ gives:

$$\begin{bmatrix}c_{11}&c_{12}&c_{13}&c_{14}&d_1\\c_{14}c_{21}-c_{24}c_{11}&c_{14}c_{22}-c_{24}c_{12}&c_{14}c_{23}-c_{24}c_{13}&0&c_{14}d_2-c_{24}d_1\\a&b&0&0&m\end{bmatrix}$$

where:

$$\begin{array}{l} a=(c_{14}c_{23}-c_{24}c_{13})(c_{14}c_{31}-c_{34}c_{11})-(c_{14}c_{33}-c_{34}c_{13})(c_{14}c_{21}-c_{24}c_{11}) \\ b=(c_{14}c_{23}-c_{24}c_{13})(c_{14}c_{32}-c_{34}c_{12})-(c_{14}c_{33}-c_{34}c_{13})(c_{14}c_{22}-c_{24}c_{12}) \\ m=(c_{14}c_{23}-c_{24}c_{13})(c_{14}d_3-c_{34}d_1)-(c_{14}c_{33}-c_{34}c_{13})(c_{14}d_2-c_{24}d_1) \end{array}$$

At this point: $a\cos⁡(t)+b\sin⁡(t)=m$

And solving for $t$ gives:

$$\begin{array}{l} t≡\arctan(am\pm b\sqrt{a^2+b^2-m^2}, bm\mp a\sqrt{a^2+b^2-m^2}) [2π] \\ v={c_{14}d_2-c_{24}d_1-(c_{14}c_{21}-c_{24}c_{11})\cos⁡(t)-(c_{14}c_{22}-c_{24}c_{12})\sin⁡(t) \over c_{14}c_{23}-c_{24}c_{13}} \\ u={d_1-c_{11}\cos⁡(t)-c_{12}\sin⁡(t)-c_{13}v \over c_{14}} \end{array}$$

However, this is under these conditions:

$$c_{14}\neq0,\space c_{14}c_{23}\neq c_{24}c_{13}\space and\space \begin{cases}am\pm b\sqrt{a^2+b^2-m^2}\neq0\\bm\mp a\sqrt{a^2+b^2-m^2}\neq0\end{cases}$$

Still not optimal...