Math 012/012B Numerical Methods and Analysis Matlab Activity 4.1 Solving Sytems of Linear Equations
Math 012/012B Numerical Methods and Analysis Matlab Activity 4.1 Solving Sytems of Linear Equations
NAME :
SCORE:
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
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.
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.