# Method for solving system of linear equations

I thought of this method:

Suppose the given equations are:

$$a_1x+a_2y+a_3z=d_1$$ $$b_1x+b_2y+b_3z=d_2$$ $$c_1x+c_2y+c_3z=d_3$$

Let $\vec{p}=x\hat{i}+y\hat{j}+z\hat{k},\:\:\:\: \vec{a}=a_1\hat{i}+a_2\hat{j}+a_3\hat{k},\:\:\:\: \vec{b}=b_1\hat{i}+b_2\hat{j}+b_3\hat{k},\:\:\:\: \vec{c}=c_1\hat{i}+c_2\hat{j}+c_3\hat{k}$

Then, $d_1=\vec{p}\cdot \vec{a},\:\:\:\: d_2=\vec{p}\cdot \vec{b},\:\:\:\: d_3=\vec{p}\cdot \vec{c}$

Now, evaluate $\vec{1}=\vec{a}, \:\:\:\:\vec{2}=\vec{b}-\frac{(\vec{a}\cdot\vec{b})\vec{a}}{|\vec{a}|^2},\:\:\:\: \vec{3}=\vec{c}-\frac{(\vec{c}\cdot\vec{a})\vec{a}}{|\vec{a}|^2}-\frac{(\vec{c}\cdot \vec{b})\vec{b}}{|\vec{b}|^2}$. The vectors $\frac{\vec{1}}{|\vec{1}|}, \frac{\vec{2}}{|\vec{2}|}, \frac{\vec{3}}{|\vec{3}|}$ are perpendicular to each other. The components of $\vec{p}$ along these three vectors are $\frac{d_1}{|\vec{a}||\vec{1}|}$, $\frac{1}{|\vec{2}|}(d_2-\frac{(\vec{a}\cdot\vec{b})d_1}{|\vec{a}|^2})$, and $\frac{1}{|\vec{3}|}(d_3-\frac{(\vec{c}\cdot\vec{a})d_1}{|\vec{a}|^2}-\frac{(\vec{c}\cdot \vec{b})d_2}{|\vec{b}|^2})$ respectively.

Therefore, $$\vec{p}=d_1\frac{\vec{1}}{|\vec{1}|^2}+\left(d_2-\frac{(\vec{a}\cdot\vec{b})d_1}{|\vec{a}|^2}\right)\frac{\vec{2}}{|\vec{2}|^2}+\left(d_3-\frac{(\vec{c}\cdot\vec{a})d_1}{|\vec{a}|^2}-\frac{(\vec{c}\cdot \vec{b})d_2}{|\vec{b}|^2}\right)\frac{\vec{3}}{|\vec{3}|^2}$$

Is this method more or less expensive than Cramer's Rule? Or Does it involve the same calculations as in Cramer's rule?

• Are you familiar with LU decomposition? Commented Dec 8, 2017 at 9:46
• @percusse I just googled it. It's a method for solving system of linear equations. Am I doing the same thing? Commented Dec 8, 2017 at 9:51
• @percusse LU decomposition is about factoring a matrix. What does this question have to do with it? Commented Dec 8, 2017 at 9:58
• That's the least expensive way of solving linear square equation sets. Commented Dec 8, 2017 at 9:59
• @percusse Oh, thanks for that. But is my method more or less expensive than Cramer's rule or is it the same thing? Commented Dec 8, 2017 at 10:01

Congrats, you rediscovered the Gram-Schmidt orthogonalization method, which generates an orthogonal base from a given set of vectors. Though your expressions are wrong (for instance, $\vec 1\cdot\vec 2\ne0$). But the intuition is correct.

As far as I know, this is not used for the numerical resolution of a system, as Gaussian elimination is more efficient. Anyway, for large system it is certainly better than Cramer (which as a cost proportional to $n!$).

For the case of $n=3$, Cramer takes $4$ determinant evaluations, each taking a sum of six triple products, and three divisions. For your method, it's you job to count the operations and compare. Be sure to write down all equations giving the final unknowns.

• @DavidReed: "Orthogonality is HUGE in numerical lin alg, although they don't do gram-Schmidt.": what's the chance that the OP can understand such a cryptic statement ?
– user65203
Commented Dec 8, 2017 at 10:23
• Oh I see, $\vec{2}=\vec{1}-(\vec{1}\cdot \vec{2}) \vec{2}$. So, we are subtracting the direction of $\vec{2}$ from $\vec{1}$ Commented Dec 8, 2017 at 10:35
• Sorry meant to say $\vec{2}=\vec{b}-(\vec{a} \cdot \vec{b})\vec{a}$ so we are subtracting direction of a from b Commented Dec 8, 2017 at 10:43
• I've corrected the formulas. Though I'm not sure how to compare the calculations involved. Wikipedia mentions a quantity called 'asymptotic complexity' whose value for Cramer's rule is $O(n+1)!$. This 'O-value' might be a measure for complexity of formulas? Commented Dec 8, 2017 at 11:24
• @RyderRude: yes, it is. But in your simple $3\times3$ case, you can count all operations "by hand", as I did.
– user65203
Commented Dec 8, 2017 at 13:22