Sie sind auf Seite 1von 6

NATIONAL UNIVERSITY OF SINGAPORE

Department of Mathematics
MA1101R Laboratory 1
Semester II 2014/15

Matrix Operations and System of Linear Equations


In this laboratory session, we introduce some very basic MATLAB commands for
performing matrix operations. We will also use two specially designed functions to
visualize linear systems in 2 or 3 variables.

Activity 1
Aim: To familiarize with basic MATLAB commands (see Laboratory 0 Worksheet) that
performs simple matrix operations.
Enter the following statements in the MATLAB command window in sequence (this
means that you hit Enter after each entering each command) and observe what happens.
Make sure you understand why you are observing what you see.
x=[1 2 3]
b=[1;

2;

3]

A=[1 2 3; 0.1 5 6; 7 8 1/2]


format rat
A
A1=[1 0; 2 1; 3 2; 4 3]
A1(2,2)
A1(4,3) (You should see an error message. Why?)
23
ans
0.3A
ans
1

B=ansb
Ax
Ax
Next, enter the appropriate commands (again in sequence) in the MATLAB command
window that allows you to do the following.
Change the display format to format short.

1 3
4

Input the matrix X = 2 0.5 2 .


1 1 1

3 1 0

Input the matrix Y = 2 0 0.3.


1 1 2
Compute the matrix product XY .
Compute the matrix product XY T .
Change the display format to format rat.
Assign the variable w to be the (2,3) entry of Y X T . (You do not need to compute
the matrix Y X T .)
Find the inverse of Y .

Activity 2
Aim: To work with matrices and recall the properties of the inverse and transpose of sums
and products of matrices. (Refer to Introduction paragraph 3(B).)
Input the following two matrices

A =

7 2 0 2
3
1 0
1
2
0 1
0
16 3 0 2

and

B =

2
2
2
1

5
17 2
6 15 1
6
19 2
2 6
0

(i) Using MATLAB, compute the products (AB)1 , A1 B 1 and B 1 A1 . What is


the relation between these matrices?
(AB)1 = B1 A1

(ii) Compute (B 2 )1 and (B 1 )2 . Are these matrices equal? Is this relation true for any
invertible matrix B?
True for any invertible matrix

(iii) Compute (A + B)1 and A1 + B 1 . Are these matrices equal?


No

(iv) Compute the products (AB)T , AT B T and B T AT . What is the relation between
these matrices?
(AB)T = BT AT

(v) Compute (A + B)T and AT + B T . Are these matrices equal?


Yes

(vi) Compute (AT )1 and (A1 )T . Are these matrices equal? Is this relation true for any
invertible matrix A?
True for any invertible matrix

Activity 3: System of Linear Equations in Two Variables


Aim: To use the specially written function plotline to investigate the number of solutions
for systems in two variables. This is a warm up for Activity 4.

Consider the following system of linear equations


a1 x + b 1 y

c1

a2 x + b 2 y

c2

a3 x + b 3 y

c3

(1)

For real values of ai , bi and ci , the graphs of these equations are lines in a two dimensional
(x, y) coordinate system. Refer to Discussion 1.1.11 of the textbook.
1. Execute the command plotline.
2. Enter three (different) equations using numbers from the set {4, 3, 2, 1, 1, 2, 3, 4}
for ai , bi , ci to form three lines such that
(i) the system has no solutions.
E.g. x + y = 1, 2x + y = 2, 3x + 2y = 1
(ii) the system has a unique solution.
E.g. x + y = 1, 2x + y = 2, 3x + 2y = 3 (Third equation can be any linear
combination of the first two.)
(iii) the system has infinitely many solutions.
E.g. x + y = 1, 2x + 2y = 2, 3x + 3y = 3. (All three equations must be scalar
multiples of each other.)
3. Repeat part 2 with ci = 0 for all equations. How many possible cases are there?
The three lines must either coincide or intersect at one point. This is because homogeneous systems always has the trivial solution.

Activity 4: System of Linear Equations in Three Variables


Aim: To use the specially written function plotplane to visualize linear equations in three
variables as planes and investigate the number of solutions for such systems. (You can
change the azimuth, elevation and the ranges for x, y and z to get a different perspective
of the planes.)
For this activity, we are concerned with objects in three dimensional space with (x, y, z)
coordinate system. Hence a linear equation looks like:
ax + by + cz = d
1. Execute the command plotplane and click on Reset.
4

2. One plane
(i) Enter (only) one equation ax + by + cz = d such that a, b, c are all non-zero.
E.g. x + 2y + 3z = 4.
(ii) Enter one equation with a, b non-zero but c = 0. Is the graph a line or a plane?
(Why?)
E.g. x + 2y = 0. This is a plane. (Although there are only two unknowns in
the equation, the unknown z still exists (with zero coefficient.) This is because
we are in the 3-D context.)
(iii) Enter one equation with a non-zero but b, c = 0. Is the graph a line or a plane
or a point? (Why?)
E.g. x = 0. This is still a plane. (See explanation in (ii).)

3. Two planes
(i) Enter two (different) equations to form two planes which (i) coincide; (ii) are
parallel but not coincide; (iii) intersect at a line.
E.g. (i) x + y + z = 1, 2x + 2y + 2z = 2.
(ii) x + y + z = 1, x + y + z = 2.
(iii) x + y + z = 1, 1x 2y + z = 2.
(ii) In each case, how many solutions does the system of two equations that you
entered have?
(i) infinitely many; (ii) none; (iii) infinitely many.
(iii) Is it possible for a system of two equations (in 3 variables) to have a unique
solution?
No. Two planes either do not intersect (which correspond to no solution) or
intersect at at least a line (which correspond to infinitely many solutions.)

4. Three planes
(i) Enter a system of three equations ax + by + cz = d such that the first equation
has a, b, c all non-zero; second one has a = 0 and b, c non-zero; third one has
a, b = 0 and c non-zero. No matter what your system is, the three planes always
intersect at a single point. Why?
E.g. x + y + z = 1, y + z = 2, z = 3. This system is in row echelon form and can
5

be uniquely solved to give exactly one solution. So correspondingly, the three


planes can only intersect at only one point.
(ii) Enter a system of three equations such that the first two equations give two
planes which are not parallel and the third one is obtained by adding a scalar
multiple of the first equation to a scalar multiple of the second equation (i.e.
Eq.3 = Eq.1 + Eq. 2). How do the three planes intersect? How is the
solution set of the system of three equations related to the solution set of the
system of the first two equations? Why ?
E.g. x + y + z = 1, y + z = 2, x + 2y + 2z = 3. The three planes intersect
at a line. The solution set of the 3 equation-system is the same as that of the
2 equation-system. This is because the third equation is obtained from the
first two, it does not impose any additional restriction to x, y, z.
(iii) Enter three (different) equations to form three planes such that no two planes
are parallel and the system of three equations has no solution. Record down
your equations.
E.g. x + y + z = 1, y + z = 2, x + 2y + 2z = 1. (Just replace the third equation
in part (ii) by another one parallel to it.)
(iv) Replace the right hand side d for all the three equations in part 4(iii) by 0.
Does the system have a solution now? Is the solution unique? Explain.
Since the system is homogeneous, it has at least the trivial solution. However,
the solution is not unique (i.e. there are infinitely many solutions). When the
non-homogeneous counterpart of the system has no solution, the corresponding
homogeneous system cannot have a unique solution.
The End

Das könnte Ihnen auch gefallen