(adsbygoogle = window.adsbygoogle || []).push({}); 1. The problem statement, all variables and given/known data

Let A and B be invertible n×n matrices and b be an n×1 vector.

Write a MATLAB function with inputs (A,B, b) to solve the equation x=B^−1*(2A^−1 + 1)b

Make use of functions "LU Facotrization, Forward Substituion and Backwards Substitution" and DO NOT calculat any matrix inverse.

2. Relevant equations

PLEASE IGNORE THIS PART FOR NOW AND SKIP TO3. The attempt at a solution

Well, I came up with the functions for LU Facotrization, Forward Substituion and Backwards Substitution;

LU Facotrization:

function [L,U]=lufactor(A)

n=length(A)

U1=A

L1=eye(n);

..for p=1:n

....for q=p+1:n

......L(q,p)=U(q,p)/U(p,p)

......U(q,p:n)=U(q,p:n)-U(p,p:n)*L(q,p)l

....end

..end

Forward Substition:

function x=forsub(L,b)

[n,n]=size(L);

x=zeros(n,1);

..for i=1:n

..... x(i)=(b(i)-L(i,1:i-1)*x(1:i-1)/L(i,i)

..end

Backwards Substition:

function x=baksub(U,b)

[n,n]=size(L);

x=zeros(n,1);

..for i=n:-1:1

..... x(i)=(b(i)-L(i,i+1:n)*x(i+1:n)/U(i,i)

..end

3. The attempt at a solution

I wrote the above functions, so that is a start,

But apart from trying to write the code, Im kind of lost in understanding the math - which is much more important.

I want to LU-factorize A and B to get and upper and lower matrix for each of A and B.

With these matracies, how would I go abouts get it's inverse?

Forword substitution solves for x in Lx = b

and

Backword substitutions solves for x in Ux=b

I do not know where to go from here

Could somebody help me out please?

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Lower/Upper Triangular Matracies and LU Factorization

**Physics Forums | Science Articles, Homework Help, Discussion**