0% found this document useful (0 votes)
118 views5 pages

Math 012/012B Numerical Methods and Analysis Matlab Activity 4.1 Solving Sytems of Linear Equations

The document discusses solving systems of linear equations using matrix inverse and left division in MATLAB. It provides example systems and matrices and shows the syntax for solving using inverse and left division. The task is to solve six systems of equations using both methods and show the MATLAB syntax and output.

Uploaded by

roseleen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
118 views5 pages

Math 012/012B Numerical Methods and Analysis Matlab Activity 4.1 Solving Sytems of Linear Equations

The document discusses solving systems of linear equations using matrix inverse and left division in MATLAB. It provides example systems and matrices and shows the syntax for solving using inverse and left division. The task is to solve six systems of equations using both methods and show the MATLAB syntax and output.

Uploaded by

roseleen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

MATH 012/012B NUMERICAL METHODS AND ANALYSIS

MATLAB ACTIVITY 4.1

SOLVING SYTEMS OF LINEAR EQUATIONS

NAME :
SCORE:

SECTION: ACTIVITY NO:

INSTRUCTOR: DATE PERFORMED/SUBMITTED

SYSTEMS OF LINEAR EQUATIONS


A System of n linear equations in n unknowns, x1, x2, x3….xn or a linear system, is a set of n linear equations each
in n unknowns.

If the linear system has no solution, it is said to be inconsistent: if it has a solution. it is called consistent.

If b1 = b2 = ….= bn, = 0, then the system is called a homogeneous system. x1= x2= xn= 0 is always a solution to a
homogeneous system; it is called the trivial solution. A solution to a homogeneous system in which not all of x1,x2 ...
xn are zero is called a nontrivial solution.

MATRIX INVERSE

An n x n matrix A is called nonsingular, or invertible, if there exist n x n matrix B such that A B = B A = In; such a B is
called an inverse of A. Otherwise, A is called singular. or noninvertible.

If A is an n x n matrix, then the linear system Ax=b has the unique solution x=A -1b. Moreover, if b= 0, then the
unique solution to the homogeneous system Ax= 0 is x =0

MATLAB® offers two approaches for finding the inverse of a matrix. We could raise A to the -1 power with the
code A^-1 or we could use the built-in function inv.
Try and Verify!!!

A =

1 1 1

1 2 3

1 3 6

>> c=inv(A)

c =

3 -3 1

-3 5 -2

1 -2 1

Solving Linear Systems using Matrix Inverse

Consider the given system of three equations with three unknowns:

We can rewrite this system of equations by using the following matrices:

Using matrix multiplication we can then rewrite the system of equations Ax=B

In MATLAB®, the matrix inverse is computed with the inv ( ) function, we can use the following set of
commands to solve this problem:
>> A=[3 2 1; -1 3 2; 1 -1 -1] and B=[10; 5; -1]
>> x= inv(A)*B
Solving Linear Systems using Matrix Left Division

In MATLAB®, we can use left division to solve the given problem. Thus, x=A\B

MATLAB® is also capable of solving problems which are either over defined or under defined using left
division.

MATLAB® uses a least squared approach to find the set of X values (which correspond to x , y , z in our
equations), which is the best match to the equations. The least squared approach minimizes the absolute value of
the difference between the calculated B values and the actual B values.
If your system of equations is under-defined MATLAB® solves the problem by setting the first variable equal
to 0, which effectively reduces the problem to two equations and two unknowns.

>> A=[3 2 1; -1 3 2; 1 -1 -1] and B=[10; 5; -1]


>> x= A\b
NAME :

SECTION: ACTIVITY NO:

INSTRUCTOR: DATE PERFORMED/SUBMITTED

TASK 1

Solve the following systems of equations, using both matrix left division and the inverse matrix method. Results should
be in rational form.

Note: Name the coefficient matrices for each item as A, B, C, D, E, and F and the constant matrices as a, b, c , d , e and
f.
MATLAB Syntax MATLAB Output MATLAB Syntax(Left Division) MATLAB Output
(Matrix Inverse)
1.

2.

3.

4.

5.

6.

You might also like