### Search

### Blogroll

### Web

### Subscribe via reader

### Subscribe via email

### Blog Stats

- 600,770 hits

### Top Posts

- Reading an excel file in MATLAB
- How do I display the data of an array in MATLAB?
- Time of death - a classic ODE problem
- How do I integrate a discrete function in MATLAB?
- How do I read data from a textfile in MATLAB?
- How do I differentiate in MATLAB?
- How do I do spline interpolation in MATLAB?
- How do I do polynomial interpolation in MATLAB
- The break statement in MATLAB
- Finding the length of curve using MATLAB

### Pages

- abuses of regression audiovisual lectures automatic integrator bubble sort buckling central divided difference champagne glass chess chopping coefficient of determination cofactor college football computational time convection coefficient experiment CSI decimal to binary conversion derivatives determinant diagonal matrix Differentiation error excel Experiments for Numerical Methods extrapolation fixed point register floating point FLOPS Forensic Science height of atmosphere higher order interpolation improper integral Integration Interpolation Introduction to Numerical Methods inverse error function Inverse of a Matrix inverse of matrix least squares regression length of curves linear regression loops lotto LU Decomposition machine epsilon matlab MATLAB solve Matrix Algebra nonlinear equation nonlinear equations numerical integration Numerical Methods open courseware optimum polynomial ordinary differential equation Ordinary Differential Equations patriot missile programming quadratic spline Regression Round off error runge runge-kutta 2nd order method significant digits simpson's 1/3 rule Simultaneous Linear Equations spline interpolation Taylor Series taylors theorem Time of Death Trapezoidal rule true error truncation error unique line unique polynomial video lectures of numerical methods
### Numerical Methods Guy

- Ugrad Student Debt: 65%students owe<$10K, avg debt:$25K, 2%students owe>$100K. Real issue - qualified jobs are missing. 1 hour ago
- How Family Game Night Makes Kids Into Better Students - Jessica Lahey - The Atlantic theatlantic.com/education/arch… 13 hours ago
- When Teachers Romanticize Their Students' Poverty - April Bo Wang - The Atlantic theatlantic.com/education/arch… 13 hours ago
- @LorenaABarba @RobertTalbert @DrEugeniaCheng we reported results in 2007 on four modalities. ijee.dit.ie/latestissues/V… 18 hours ago
- National Science Foundation (NSF) Discoveries - (Really) learning physics zite.to/1qIVuSd 6 days ago

# Category Archives: Simultaneous Linear Equations

## Computational Time to Find Determinant Using Gaussian Elimination

The time it would take to find the determinant of a matrix using the Gaussian Elimination is many-many orders less than when the cofactor method is used. In this blog, we derive the formula for a typical amount of computational time it would take to find the determinant of a nxn matrix using the forward elimination part of the Naive Gauss Elimination method. The time is compared with that using the cofactor method.

This post is brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at http://numericalmethods.eng.usf.edu, the textbook on Numerical Methods with Applications available from the lulu storefront, the textbook on Introduction to Programming Concepts Using MATLAB, and the YouTube video lectures available at http://numericalmethods.eng.usf.edu/videos. Subscribe to the blog via a reader or email to stay updated with this blog. Let the information follow you.

## Computational Time to Find Determinant Using CoFactor Method

The time it would take to find the determinant of a matrix using the cofactor method can be daunting. A student may not realize this as they may be limited to finding determinants of matrices of order 4×4 or less by hand. In this blog, we derive the formula for a typical amount of computational time it would take to find the determinant of a nxn matrix using the cofactor method.

This post is brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at http://numericalmethods.eng.usf.edu, the textbook on Numerical Methods with Applications available from the lulu storefront, the textbook on Introduction to Programming Concepts Using MATLAB, and the YouTube video lectures available at http://numericalmethods.eng.usf.edu/videos. Subscribe to the blog via a reader or email to stay updated with this blog. Let the information follow you.

Posted in Numerical Methods, Simultaneous Linear Equations

Tagged cofactor, computational time, determinant

## Computational Time for Forward Substitution

In the previous blog, we found the computatational time for back substitution. This is a blog that will show you how we can find the approximate time it takes to conduct forward substitution, while solving simultaneous linear equations. The blog assumes a AMD-K7 2.0GHz chip that uses 4 clock cycles for addition, subtraction and multiplication, while 16 clock cycles for division. Note that we are making reasonable approximations in this blog. Our main motto is to see what the computational time is proportional to – does the computational time double or quadruple if the number of equations is doubled.

The pdf file of the solution is also available.

This post is brought to you by

- Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at http://numericalmethods.eng.usf.edu,
- the textbook on Numerical Methods with Applications available from the lulu storefront,
- the textbook on Introduction to Programming Concepts Using MATLAB, and
- the YouTube video lectures available at http://numericalmethods.eng.usf.edu/videos

Subscribe to the blog via a reader or email to stay updated with this blog. Let the information follow you.

## Computational Time for Back Substitution

This is a blog that will show you how we can find the approximate time it takes to conduct back substitution, while solving simultaneous linear equations using Gaussian elimination method. The blog assumes a AMD-K7 2.0GHz chip that uses 4 clock cycles for addition, subtraction and multiplication, and 16 clock cycles for division. Note that we are making reasonable approximations in this blog. Our main motto is to find how the computational time is related to the number of equations.

The pdf file of the solution is also available.

This post is brought to you by

- Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at http://numericalmethods.eng.usf.edu,
- the textbook on Numerical Methods with Applications available from the lulu storefront,
- the textbook on Introduction to Programming Concepts Using MATLAB, and
- the YouTube video lectures available at http://numericalmethods.eng.usf.edu/videos

Subscribe to the blog via a reader or email to stay updated with this blog. Let the information follow you.

## How do I solve simultaneous linear equations given in equation form?

Many students ask me how do I do this or that in MATLAB. So I thought why not have a small series of my next few blogs do that. In this blog, I show you how to solve simultaneous linear equations given in equation form.

- The MATLAB program link is here.
- The HTML version of the MATLAB program is here.
**DO NOT COPY AND PASTE THE PROGRAM BELOW BECAUSE THE SINGLE QUOTES DO NOT TRANSLATE TO THE CORRECT SINGLE QUOTES IN MATLAB EDITOR.****DOWNLOAD THE MATLAB PROGRAM****INSTEAD**

%% HOW DO I DO THAT IN MATLAB SERIES?

% In this series, I am answering questions that students have asked

% me about MATLAB. Most of the questions relate to a mathematical

% procedure.

%% TOPIC

% How do I solve a set of simultaneous linear equations

% given in equation form?

%% SUMMARY

% Language : Matlab 2008a;

% Authors : Autar Kaw;

% Mfile available at

% http://numericalmethods.eng.usf.edu/blog/sle_equations.m;

% Last Revised : August 22, 2009;

% Abstract: This program shows you how to solve a set of

% simultaneous linear equations given in equation form?

% .

clc

clear all

clf

%% INTRODUCTION

disp(‘ABSTRACT’)

disp(‘ This program shows you how to solve a’)

disp(‘ set of simultaneous linear equations given in equation form’)

disp(‘ ‘)

disp(‘AUTHOR’)

disp(‘ Autar K Kaw of http://autarkaw.wordpress.com’)

disp(‘ ‘)

disp(‘MFILE SOURCE’)

disp(‘ http://numericalmethods.eng.usf.edu/blog/sle_equations.m’)

disp(‘ ‘)

disp(‘LAST REVISED’)

disp(‘ August 22, 2009′)

disp(‘ ‘)

%% INPUTS

% Enter the equations

eqn1=’12*a+23*b+39*c=29′;

eqn2=’13*a+17*b+19*c=37′;

eqn3=’21*a+23*b+29*c=59′;

%% DISPLAYING INPUTS

disp(‘ ‘)

disp(‘INPUTS’)

disp(‘________________________’)

disp(‘Equations’)

disp(‘________________________’)

disp(eqn1)

disp(eqn2)

disp(eqn3)

%% THE CODE

% The solution

X=solve(eqn1,eqn2,eqn3);

% Assigning the output

a=double(X.a);

b=double(X.b);

c=double(X.c);

%% DISPLAYING OUTPUTS

disp(‘ ‘)

disp(‘OUTPUTS’)

disp(‘________________________’)

disp(‘Solution Vector’)

disp(‘________________________’)

fprintf(‘\nValue of a= %g’,a)

fprintf(‘\nValue of b= %g’,b)

fprintf(‘\nValue of c= %g’,c)

disp(‘ ‘)

disp(‘________________________’)

This post is brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at http://numericalmethods.eng.usf.edu, the textbook on Numerical Methods with Applications available from the lulu storefront, and the YouTube video lectures available at http://numericalmethods.eng.usf.edu/videos and http://www.youtube.com/numericalmethodsguy

Subscribe to the blog via a reader or email to stay updated with this blog. Let the information follow you.

## How do I solve a set of simultaneous linear equations given in matrix form?

Many students ask me how do I do this or that in MATLAB. So I thought why not have a small series of my next few blogs do that. In this blog, I show you how to solve simultaneous linear equations given in matrix form.

- The MATLAB program link is here.
- The HTML version of the MATLAB program is here.
**DO NOT COPY AND PASTE THE PROGRAM BELOW BECAUSE THE SINGLE QUOTES DO NOT TRANSLATE TO THE CORRECT SINGLE QUOTES IN MATLAB EDITOR.****DOWNLOAD THE MATLAB PROGRAM****INSTEAD**

%% HOW DO I DO THAT IN MATLAB SERIES?

% In this series, I am answering questions that students have asked

% me about MATLAB. Most of the questions relate to a mathematical

% procedure.

%% TOPIC

% How do I solve a set of simultaneous linear equations?

%% SUMMARY

% Language : Matlab 2008a;

% Authors : Autar Kaw;

% Mfile available at

% http://numericalmethods.eng.usf.edu/blog/sle.m;

% Last Revised : August 12, 2009;

% Abstract: This program shows you how to solve a set of simultaneous linear

% equations?

% .

clc

clear all

clf

%% INTRODUCTION

disp(‘ABSTRACT’)

disp(‘ This program shows you how to solve a’)

disp(‘ set of simultaneous linear equations’)

disp(‘ ‘)

disp(‘AUTHOR’)

disp(‘ Autar K Kaw of http://autarkaw.wordpress.com’)

disp(‘ ‘)

disp(‘MFILE SOURCE’)

disp(‘ http://numericalmethods.eng.usf.edu/blog/sle.m’)

disp(‘ ‘)

disp(‘LAST REVISED’)

disp(‘ August 12, 2009′)

disp(‘ ‘)

%% INPUTS

% Enter the coefficient matrix of the equation [A][X]=[C]

A=[12 23 39; 13 17 19; 21 23 29];

% Enter the right hand side vector

C=[29; 37; 59];

%% DISPLAYING INPUTS

disp(‘ ‘)

disp(‘INPUTS’)

disp(‘________________________’)

disp(‘Coefficient Matrix’)

disp(‘________________________’)

dataval=[A];

disp(dataval)

disp(‘________________________’)

disp(‘Right hand side vector’)

disp(‘________________________’)

dataval=[C];

disp(dataval)

disp(‘________________________’)

%% THE CODE

% The solution

X=A\C;

%% DISPLAYING OUTPUTS

disp(‘ ‘)

disp(‘OUTPUTS’)

disp(‘________________________’)

disp(‘Solution Vector’)

disp(‘________________________’)

dataval=[X];

disp(dataval)

disp(‘________________________’)

his post is brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at http://numericalmethods.eng.usf.edu, the textbook on Numerical Methods with Applications available from the lulu storefront, and the YouTube video lectures available at http://numericalmethods.eng.usf.edu/videos and http://www.youtube.com/numericalmethodsguy

## So what does this mean that the computational time is proportional to some power of n in Gaussian Elimination method?

In a previous post, we talked about why LU Decomposition is computationally more efficient than Gaussian Elimination in some cases. The argument was based on how much computational time does each of the methods take. For example, we said that for back substitution in both methods, the computational time is approximately proportional to .

**How did we find that for back substitution the computational time is approximately proportional to ****?**

The amount of time it takes to conduct back substitution depends on the number of floating point operations (FLOPs) needed. Depending on how many FLOPs the computer can execute in a second called FLOPS (*note the upper case S to distinguish between FLOPs and FLOPS*), that will the determine the actual computational time. (A typical Pentium 4 PC conducts to the order of FLOPS; a state-of-art supercomputer conducts to the order of FLOPS; in 1983 the PC with a 8087 chip may have conducted to the order of FLOPS).

To keep things simple, let’s only count the multiplication/division FLOPs in back substitution as time used by multiplication and division is higher than addition and subtraction (*Multiplication may take twice and division as much as thrice the time it takes for addition and subtraction*).

In back substitution, we start with the last equation. The last equation involves one division, second last equation involves one multiplication and one division, the third last equation involves two multiplications and one division, and so on. So the number of multiplication/divisions FLOPs is 1 for last equation, 2 for second last equation, 3 for third last equation, that is, for all equations, . For large n, this number is approximately .

This post brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at http://numericalmethods.eng.usf.edu

## Rusty on Matrix Algebra

Eight years ago, the Florida legislature decided to reduce the number of credit hours it takes a state university student to graduate with an undergrad engineering degree. The number of credit hours were reduced from 136 to 128. One of the courses that got the ax in the Mechanical Engineering Department at USF was a 2-credit hour Linear Algebra course. There are many other universities in the nation that have done the same.

**So how do students learn Linear Algebra when the course is one of the requirements for accreditation of engineering programs? **

Some universities have bundled Linear Algebra course content into courses such as *Quantitative Methods* where students are expected, in many cases, to learn linear algebra, a programming language/computational system, and complex analysis. Other curriculums have dispersed the Linear Algebra content into different courses such as the topic of special matrices in *Programming*, simultaneous linear equations in *Statics*, and eigenvalues/eigenvectors in *Vibrations*, etc. Unless quality controls are introduced carefully, the content/depth of Linear Algbera in such courses can vary substantially between courses and instructors. Such control is impossible in metropolitan universities such as USF where a large proportion of students transfer from community colleges.

To have a resource that would be a self-explanatory as well as get the students exposed to Linear Algebra applications motivated me to write a simple *Introduction to Matrix Algebra *book*. *The book consists of ten chapters spanning fundamentals of matrix algebra, numerical methods for solving a set of equations, and a treatment of adequacy of solutions and eigenvalues.

Since 2002, the Introduction to Matrix Algebra book has been downloaded free of charge by more than 30,000 users from 50 different countries, and the feedback has been humbling and fulfilling.

Since April 2008, the book has also been made available for a nominal charge via lulu.com as a pdf file as well as a soft cover book. Proceeds from the book are allowing me to expand the book with more examples/problems and additional chapters.

Since my belief continues to embrace open and uncomplicated dissemination, eight individual chapters of the book in pdf form are still available free of charge. So one may ask the following question. Why should I buy the book when it is available free of charge? For answer to this question, click here

For more details about the book, visit the book website at http://autarkaw.com/books/matrixalgebra/index.html

This post brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at http://numericalmethods.eng.usf.edu

Posted in Numerical Methods, Simultaneous Linear Equations, Uncategorized

Tagged Matrix Algebra

## LU Decomposition takes more computational time than Gaussian Elimination! What gives?

If you are solving a set of simultaneous linear equations, LU Decomposition method (involving forward elimination, forward substitution and back substitution) would use more computational time than Gaussian elimination (involving forward elimination and back substitution, but NO forward substitution).

**So why use and waste time talking about LU Decomposition?**

Because, LU Decomposition is computationally more efficient than Gaussian elimination when we are solving several sets of equations with the same coefficient matrix but different right hand sides. Case in point is when you are finding the inverse of a matrix [A]. If one is trying to find the inverse of *n*x*n* matrix, then it implies that one needs to solve *n* sets of simultaneous linear equations of [A][X]=[C] form with the *n* right hand sides [C] being the *n* columns of the *n*x*n *identity matrix, while the coefficient matrix [A] stays the same.

The computational time taken for solving a single set of *n* simultaneous linear equations is as follows:

**Forward elimination**: Proportional to

**Back substitution**: Proportional to

**Forward substitution**: Proportional to

So for LU decomposition method used to find the inverse of a matrix, the computational time is proportional to . Remember that the forward elimination only needs to be done only once on [A] to generate the L and U matrices for the LU decomposition method. However the forward and back substitution need to be done *n* times.

Now for Gaussian Elimination used to find the inverse of a matrix, the computational time is proportional to . Remember that both the forward elimination and back substitution need to be done *n* times.

Hence for large *n*, for LU Decomposition, the computational time is proportional to , while for Gaussian Elimination, the computational time is proportional to . So for large *n*, the ratio of the computational time for Gaussian elimination to computational for LU Decomposition is .

As an example, to find the inverse of a 2000×2000 coefficient matrix by Gaussian Elimination would take n/4=2000/4=500 times the time it would take to find the inverse by LU Decomposition.

So are you convinced now why we use LU Decomposition in certain cases? For textbook notes on this issue, examples of LU Decomposition to solve a set of equations, and finding inverse of a matrix using LU Decomposition, click here.

**Reference**: Numerical Methods for the STEM Undergraduate, http://numericalmethods.eng.usf.edu/topics/lu_decomposition.html

This post brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at http://numericalmethods.eng.usf.edu

Posted in Numerical Methods, Simultaneous Linear Equations

Tagged Inverse of a Matrix, LU Decomposition