Hello I am trying to solve the following system using the cholesky method in Matlab
A = [1 -1; -1 5];
L = [ 1 0;
-1 2]; //Lower Triangular Decomp via choleksy method
Lt = [1 -1; 0 2]; //L transpose
B = [-1; 9]; //B vector since were solving Ax = B -> L*Lt*x = B
Linv = inv(L) //calculating inverse of L
B*Linv //Computing multiplication
Now... I dont understand why I get the error
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix.
I am guessing its because Im multyplying in this order? 2 x 1 * 2 x 2 so the dimensions dont match up. Maybe I dont understand how this process works fully, but I thought in order to solve the system I would have to eliminate L by multiplying both sides by L inverse.
You are doing
B*Linvbut what you want isLinv*B.This is because if $LL^{T}\mathbf{x} = \mathbf{b}$, then we can multiply both sides on the left by $L^{-1}$ to obtain
$$L^{-1}LL^{T}\mathbf{x} = L^{-1}\mathbf{b}\Rightarrow L^{T}\mathbf{x} = L^{-1}\mathbf{b}.$$
(Remember, for matrix multiplication, $AB$ is not the same thing as $BA$ in general. Also in this case, $\mathbf{b}L^{-1}$ would not make sense because in a matrix product like $AB$, the number of columns in the first matrix ($A$) must match the number of rows in the second matrix ($B$).)