Question

Solve the following linear system of equations.

please answer by giving Matlab code for this question

Solve the following linear system of equations. 

x₁+3 x₂-x₃+2 x₄+3 x₅=5

x₁+2 x₂-x₃+4 x₄+9 x₅=-3

3 x₁-5 x₂+3 x₃+2 x₄-x₅=7

2 x₂+x₃+2 x₅=-3

x₁-x₂+2 x₅=1


Using 

-LU Factorization. 

-Cramer's rule.

1 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB code:

% Defining the equation given in matrix form

% Ax = b form

A = [1 3 -1 2 3; 1 2 -1 4 9; 3 -5 3 2 -1; 0 2 1 0 2; 1 -1 0 0 2];

b = [5; -3; 7; -3; 1];

% Finding LU decomposition of A matrix

[L , U] = lu(A);

% To get solution using LU decomposition

% We can modify the solution as LUx = b

% Lets assume Ux = y

% then we will have Ly = b

% we will solve 'y' first and then x

y = inv(L) * b;

x_lu = inv(U) * y;

% Displaying the result

disp("The value of x using LU decomposition are")

disp(x_lu);

% Part b)

% using cramers rule

det_A = det(A);

det_x = [det([b A(: , 2:end)]); det([A(: , 1) b A(: , 3:end)]); det([A(: , 1:2) b A(: , 4:end)]); ...

mdet([A(: , 1:3) b A(: , 5)]); det([A(: , 1:4) b])];

x_c = det_x ./ det_A ;

% Displaying the result

disp("The value of x using cramer method are")

disp(x_c);


1 2 3 % Defining the equation given in matrix form % Ax = b form A = [1 3 -1 2 3; 1 2 -1 4 9; 3-5 3 2 -1; 0 2 1 0 2; 1 -1 0 0

OUTPUT:

The value of x using LU decomposition are 4.4286 0.7013 -1.6753 0.4416 -1.3636 The value of x using cramer method are 4.4286

Add a comment
Answer #2

nice code but check line 25 of the code image and remove m from mdet......

answered by: Anumah, Adeiza Stephen
Add a comment
Know the answer?
Add Answer to:
Solve the following linear system of equations.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT