guassian elimination with partial pivoting
1 view (last 30 days)
hi, i'm trying to solve for a system of linear equation in form of matrices and i have made a function to perform the backward subtitute after doing all the pivoting and solve for the case where it has infinite solution only. this is what i got so far:
function x = backsub_syms(U,b)
n = length(b);
syms x [1 n]
u = rank(U);
p = n - u;
if (p == 1)
else if (p>1)
it is working perfectly fine only when the 1 free variable (p = 1) so in case p is larger than 1, i dont know how to approach this since this can only use symbolic variable to calculate. can some one give me an idea or a hint to complete the '??????' part
Keyur Mistry on 21 Sep 2020
I understand that you want to generalize your code for ‘p>1’. Find following hints to achieve it.
As there will be ‘p’ numbers of free variables, symbolic variable array can be defined ‘t1’,’t2’,…’tp’ as below
syms t [1 p];
x(1,i) = t(1,p-n+i); %if first non-zero entry in each row of U is diagonal element
It is necessary to find first non-zero entry for each row of ‘U’ to get correct solution. For the same find below code.
x(1,j) = m;
I hope these are useful hints to find your solution.