Applied Mathematics II
Course Concern: Hammad Ullah Bhutto
Department of Mathematics, University of Sindh
Summary
2
Array-to-Array Operations
Array-to-Array Operations
Array-to-array operations mainly involve algebraic
operations like addition, subtraction, multiplication and
inverse-multiplication (exponentiation is a
manifestation of multiplication).
There can be more sophisticated operations possible in
MATLAB that we will skip in this course.
Remember that a vectors and matrices are classified as
arrays but there could be more complicated arrays such 4
as stacked matrices or tensors.
Array-to-Array Operations
Any operation between any two is possible if the arrays
are compatible.
Each operation has its own criteria for arrays which we
will briefly discuss for the sake of revision.
5
Array-to-Array Operators
in MATLAB
Array-to-Array Operations
Characters for operations on arrays in MATLAB are as
follows:
for addition (unary and binary).
for subtraction (unary and binary).
for multiplication (binary).
raising powers to an array (unary).
for transpose (unary).
7
for inverse multiplication (binary).
Addition/Subtraction
of Arrays
Array Addition/Subtraction
To add (subtract) two arrays, the size of the arrays must
be taken care of.
Toadd (subtract) array and (from) array , both must
have the dimensions.
To add array and the MATLAB syntax is .
If the arrays aren’t compatible for addition/subtraction,
MATLAB will terminate processing and return an error.
9
Multiplication of Arrays
Array Multiplication
Two arrays are compatible for multiplication if they
have a specific arrangement of components
In matrices, for example, multiplication is possible if the
left matrix has the same number of column as the
number of rows in the right matrix.
For example, a matrix of order is compatible for
multiplication with a matrix of order .
11
Array Multiplication (cont.)
Say is a vector of size and is vector of size , and and
are matrices of order then:
Multiplication in MATLAB
Vector-vector multiplication
Matrix-matrix multiplication
Matrix-vector multiplication
12
Raising an Array to a Power
Array Exponentiation
A matrix is compatible for multiplication with itself iff it
is square.
Multiplying a matrix with itself times is the same as
raising it to the power.
Also, the exponentiation will yield a matrix of similar
dimensions.
14
Array Exponentiation (cont.)
To raise a square matrix to any power in MATLAB, the
unary operator is used.
For example, to raise a square matrix to the power of ,
the MATLAB syntax is .
15
Array Exponentiation (cont.)
Using MATLAB, verify that is a nilpotent matrix of
degree 3.
16
Transpose of an Array
Array Transpose
Transpose of a matrix yields a matrix such that each
row-vector in is a column-vector in with the same
correspondence.
For example, transpose of is
In books, we write it as .
18
Array Transpose (cont.)
Note that the transpose also switch the dimensions of
the array. The row number becomes the column
number and vice-versa.
If has dimensions then will have dimensions .
19
Array Transpose (cont.)
To transpose a matrix in MATLAB, use operator.
Array in MATLAB MATLAB input MATLAB return
20
Multiplying the Inverse
of a Matrix with another Array
Inverse Multiplication of an Array
Recall that a matrix is an operator.
Being operators, matrices can’t divide. Instead they are
operated inversely. For that, inverse of a matrix is to be
operated on the object.
Encountering inverse of a matrix is common when
solving matrix equations, however, finding the inverse
of a matrix is a very costly process, especially when the
matrix has large dimensions. 22
Inverse Multiplication of an Array (cont.)
The following example is a manifestation of how
physical problems can be translated into mathematics
and solved using computer applications.
For those who are curious, the following example is the
discretization of the Laplace equation which is a basic
partial differential equation that occurs in heat and
diffusion equations.
23
Inverse Multiplication of an Array (cont.)
Consider the model:
30
𝑢1 𝑢2
100 25
𝑢3 𝑢4
24
75
Inverse Multiplication of an Array (cont.)
Temperature of the nodes and can be
roughly estimated using the mean
temperatures of the neighboring nodes, i.e.
25
Inverse Multiplication of an Array (cont.)
The system can be rearranged as:
26
Inverse Multiplication of an Array (cont.)
The system can then be transformed into a matrix
equation:
27
Inverse Multiplication of an Array (cont.)
The equation can be solved for the unknown vector as
follows:
Note that the equation has an inverse matrix.
28
Inverse Multiplication of an Array (cont.)
The inverse matrix here is multiplied by a vector.
29
Inverse Multiplication of an Array (cont.)
To multiply an inverted matrix by a vector , we have the
hardworking backslash operator
Mathematical Expression MATLAB Syntax
30
Inverse Multiplication of an Array (cont.)
To solve the above problem in MATLAB, store in and in
and find .
31
Inverse Multiplication of an Array (cont.)
The solution vector is:
Which is an estimated temperature at the corresponding
node in the system.
32
Inverse Multiplication of an Array (cont.)
Note that when the inverse of a matrix is required, it
can be found in MATLAB by command.
However, when inverse-multiplication is needed, the
backslash operator is strongly advised.
Both the following expressions yield similar results but
are not equivalent:
MATLAB Syntax MATLAB Syntax
33
Inverse Multiplication of an Array (cont.)
The backslash operator is considerably faster than the
matrix-inversion function.
The inverse function can work only with square
matrices, whereas the backslash operator is not limited
to square matrices.
the backslash operator should not be confused with the
forwardslash operator that is used for division.
34
.
End
35