EGR 106 Lecture 4 Array Mathematics - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

EGR 106 Lecture 4 Array Mathematics

Description:

In linear algebra, the matrix expression F = A * B means ... min and max can yield both the value and its location. default is the first result ... – PowerPoint PPT presentation

Number of Views:24
Avg rating:3.0/5.0
Slides: 31
Provided by: gatew318
Category:

less

Transcript and Presenter's Notes

Title: EGR 106 Lecture 4 Array Mathematics


1
EGR 106 Lecture 4Array Mathematics
  • Linear Algebraic Operations
  • Additon/Subtraction
  • Multiplication
  • Division
  • Element by Element Operations
  • Row/Column Based Operations
  • Textbook 3.1-3.8

2
Element by Element Math Operations
  • For arrays of identical sizes, addition is
    defined term by term
  • the command F A B means
  • F(r,c) A(r,c) B(r,c)
  • for all row and column pairs r,c

element-by-element addition
3
  • For example
  • Notes
  • Arrays must be of identical sizes
  • One can be a scalar (it is sized up)
  • Subtraction is identical

4
  • The other basic math operations work element by
    element using the dot notation (with A,B the same
    sizes)
  • multiplication
  • F A . B ? F(r,c) A(r,c) B(r,c)
  • division
  • F A ./ B ? F(r,c) A(r,c) / B(r,c)
  • exponentiation
  • F A . B ? F(r,c) A(r,c) B(r,c)

note periods!
5
  • For example

6
  • One could be scalar a 1 2 3 b 2

7
  • Built-in functions also work element-by-element
  • log and exp
  • trigonometric
  • etc.

8
Array Multiplication (Linear Algebra)
  • In linear algebra, the matrix expression F A
    B means
  • Entries are dot products of rows of the first
    matrix with columns of the second

9
  • For example

10
  • Notes
  • The operation is generally not commutative
  • AB ? BA
  • The number of columns of the 1st must match the
    number of rows of the 2nd

n by k
k by m
n by m
11
  • For example, here multiplication works both ways,
    but is not commutative

quite different!
12
  • And here it doesnt work at all

13
Application of Multiplication
  • Application of matrix multiplication n
    simultaneous equations in m unknowns (the xs)

14
  • For example
  • In matrix form this is A x b
  • with

15
  • In general A x b
  • A is n by m
  • x is m by 1
  • b is n by 1


column vectors (lower case)
16
  • Wide Spread Applications in Engineering currents
    in circuits traffic flow, static equilibrium
    problems, fluid flow in piping systems, heat flow
    in thermodynamics, computational simulation

17
Array Division
  • Recall the command eye(n)
  • This result is the array
  • multiplication identity matrix I
  • For any array A
  • A I I A A

must be properly sized!
18
  • Imagine that for square arrays A and B we have
  • A B B A I
  • then we call them inverses
  • A B1 B A1
  • In Matlab A -1 or inv(A)
  • When does A1 exist?
  • A is square
  • A has a non-zero determinant (det(A))

19
  • For example

20
  • Solving A x b
  • Assume that A is square and det(A) ? 0
  • Multiply both sides by A1 on the left
  • A1 A x A1 b
  • so x A1 b
  • In Matlab, x A \ b or x inv(A)b

I
x
backwards slash
21
  • For example
  • Check your work

22
General Linear Equation Solving (not in the
book!)
  • Problem types
  • overdetermined
  • underdetermined
  • Solution methods
  • Cramer's method
  • Gaussian elimination
  • inverse matrix
  • others
  • Solution situations
  • non-singular
  • one unique solution
  • singular
  • no solution
  • many solutions
  • Matlab does them all

23
Vector Based Operations
  • Some operations analyze a vector to yield a
    single value. For example

sums the elements
24
  • Other operations for a vector A
  • Minimum min(A)
  • Maximum max(A)
  • Median median(A)
  • Mean or average mean(A)
  • Standard deviation std(A)
  • Product of the elements prod(A)

25
  • Some operators yield two results
  • min and max can yield both the value and its
    location
  • default is the first result

26
  • Some operators yield vector results
  • size(A) weve already seen
  • sort

27
  • Or multiple vectors

28
  • Finally, when applied to an array, these
    operators perform their action on columns

29
  • Unless you instruct it to work on rows!

the 2 means use the 2nd dimension i.e. spanning
the columns
30
  • Use help to discover how to use these work
Write a Comment
User Comments (0)
About PowerShow.com