Purchase Solution

Matlab: Naive Gaussian Elimination and L-U Decomposition

Not what you're looking for?

Ask Custom Question

Please find the question attached to the document below.

function [x] = gaussel(A,b)
% [x] = gaussel(A,b)
%
% This subroutine will perform Gaussian elimination
% and back substitution to solve the system Ax = b.
% INPUT : A - matrix for the left hand side.
% b - vector for the right hand side
%
% OUTPUT : x - the solution vector.
N = max(size(A));
% Perform Gaussian Elimination
for j=2:N,
for i=j:N,
m = A(i,j-1)/A(j-1,j-1);
A(i,:) = A(i,:) - A(j-1,:)*m;
b(i) = b(i) - m*b(j-1);
end
end
% Perform back substitution
x = zeros(N,1);
x(N) = b(N)/A(N,N);
for j=N-1:-1:1,
x(j) = (b(j)-A(j,j+1:N)*x(j+1:N))/A(j,j);
end

% End of function

a)The above programme solves a linear system of equations using naïve Gaussian elimination.
Modify this programme so that it outputs upper and lower triangular matrices of LU factorisation. The header line of the modified function should read [x, L, U] = gaussel(A, b)
Use this function, to solve the system Ax = b, where
b) Use the LU factorisation of A obtained above to solve the system Ax = c, where

You can use the 'backslash' Matlab operator for solving the systems of equations with L and U.

Attachments
Purchase this Solution

Solution Summary

In this solution, we modify the naive Gaussian elimination code to yield the L and U matrices as well, and apply the result to solving examples of linear equations.

Purchase this Solution


Free BrainMass Quizzes
Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

C# variables and classes

This quiz contains questions about C# classes and variables.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Javscript Basics

Quiz on basics of javascript programming language.