Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Agenda
1. Tools
2. Matrices
3. Least squares
4. Propagation of variances
5. Geometry
5. Math
1
1. Tools
Excel
Matlab
Mathcad
Labview
5. Math
1. Tools
2
Excel
Spreadsheet
Readily available
Solver functions
5. Math
1. Tools
3
Matlab
Matrix based
Powerful analytical tool
Handles transforms well
Easy to program
5. Math
1. Tools
4
Mathcad
Mathematical tool
Evolving into handling transfer functions
Has special programming language
Documentation closer to real math
5. Math
1. Tools
5
Labview
Powerful analysis tool
Uses graphical language to translate
concepts into C-code and then execute
5. Math
1. Tools
6
2. Matrices (1 of 2)
Addition
Subtraction
Multiplication
Vector, dot product, & outer product
Transpose
Determinant of a 2x2 matrix
Cofactor and adjoint matrices
Determinant
Inverse matrix
5. Math
2. Matrices
7
Matrices (2 of 2)
Orthogonal matrix
Hermetian matrix
Unitary matrix
5. Math
2. Matrices
8
Addition (1 of 2)
C=A+B
1 -1 0
A= -2 1 -3
2 0 2
1
B= 0
-1
-1 -1
4 2
0 1
2
C= -2
1
-2 -1
5 -1
0 3
cIJ = aIJ + bIJ
5. Math
2. Matrices
9
Addition (2 of 2)
1
-2
2
A
-1
1
0
+
0
-3
2
1
0
-1
B
-1
4
0
-1
2
1
=
2
-2
1
C
-2
5
0
-1
-1
3
1. Highlight area for answer
2. Type "="
3. Highlight area of first matrix
4. Type "+"
5. Highlight area for second matrix
6. Type CTL+SHIFT+ENTER
Matrix addition using Excel
5. Math
2. Matrices
10
Subtraction (1 of 2)
C=A-B
1 -1 0
A= -2 1 -3
2 0 2
1
B= 0
-1
-1 -1
4 2
0 1
0 0 1
C= -2 -3 -5
3 0 1
cIJ = aIJ - bIJ
5. Math
2. Matrices
11
Subtraction (2 of 2)
1
-2
2
A
-1
1
0
0
-3
2
1
0
-1
B
-1
4
0
-1
2
1
=
0
-2
3
C
0
-3
0
1
-5
1
1. Highlight area for answer
2. Type "="
3. Highlight area of first matrix
4. Type "-"
5. Highlight area for second matrix
6. Type CTL+SHIFT+ENTER
Matrix subtraction using Excel
5. Math
2. Matrices
12
Multiplication (1 of 2)
C=A*B
1 -1 0
A= -2 1 -3
2 0 2
1
B= 0
-1
-1 -1
4 2
0 1
C=
1
1
0
-5 -3
6 1
-2 0
cIJ = aI1 * b1J + aI2 * b2J + aI3 * b3J
5. Math
2. Matrices
13
Multiplication (2 of 2)
1
-2
2
A
-1
1
0
*
0
-3
2
1
0
-1
B
-1
4
0
=
-1
2
1
1
1
0
C
-5
6
-2
-3
1
0
1. Highlight area for answer
2. Type "= MMULT(", or use INSERT FUNCTION
3. Highlight area of first matrix
4. Type ","
5. Highlight area for second matrix
6. Type CTL+SHIFT+ENTER
Matrix multiplication using Excel
5. Math
2. Matrices
14
Transpose (1 of 3)
B=AT
1 -1 0
A= -2 1 -3
2 0 2
1
B= -1
0
-2
1
-3
2
0
2
bIJ = aJI
5. Math
2. Matrices
15
Transpose (2 of 3)
1
-2
2
A
-1
1
0
0
-3
2
A-transpose
1
-2
2
-1
1
0
0
-3
2
1. Highlight area for answer
2. Type "= TRANSPOSE(", or use INSERT FUNCTION
3. Highlight area of matrix
4. Type CTL+SHIFT+ENTER
Matrix transpose using Excel
5. Math
2. Matrices
16
Transpose (3 of 3)
(AB)T = BT AT
1 -1 0
A= -2 1 -3
2 0 2
1 -2
AT = -1 1
0 -3
5. Math
2
0
2
1
B= 0
-1
1
BT = -1
-1
-1 -1
4 2
0 1
0
4
2
2. Matrices
-1
0
1
1
(AB)T = -5
-3
BTAT =
1
-5
-3
1 0
6 -2
1 0
1 0
6 -2
1 0
17
Vector, dot & outer products (1 of 2)
A vector v is an N x 1 matrix
Dot product = inner product = vT x v = a
scalar
Outer product = v x vT = N x N matrix
5. Math
2. Matrices
18
Vector, dot & outer products (2 of 2)
v
1
2
3
1
v'
2
3
inner
v'*v
14
1
2
3
outer
v*v'
2
3
4
6
6
9
Matrix inner and outer products using Excel
5. Math
2. Matrices
19
Determinant of a 2x2 matrix
B
=
1 -1
-2 1
= -1
2x2 determinant = b11 * b22 - bI2 * b21
5. Math
2. Matrices
20
Cofactor and adjoint matrices
1 -1 0
A= -2 1 -3
2 0 2
1 -3
-2 -3
0 2
2 2
B = cofactor = - -1
0
0
2
1
2
0
2
-1 0 - 1
0 -3
-2
C=BT = adjoint=
5. Math
0
-3
-2
2
-
1
0
1 -1
2 0
2 -2 -2
= 2 2 -2
3 3 -1
1 -1
-2 1
2 2 3
-2 2 3
-2 -2 -1
2. Matrices
21
Determinant
determinant of A =
1 -1
0
1 -1 0
-2 1 -3
2 0 2
2
-2
-2
=4
=4
The determinant of A = dot product of any row in A times
the corresponding column in the adjoint matrix =
dot product of any row (or column) in A times
the corresponding row (or column) in the cofactor matrix
5. Math
2. Matrices
22
Inverse matrix (1 of 3)
B = A-1 =adjoint(A)/determinant(A) =
1 -1 0
-2 1 -3
2 0 2
0.5 0.5 0.75
-0.5 0.5 0.75
-0.5 -0.5 -0.25
0.5 0.5 0.75
-0.5 0.5 0.75
-0.5 -0.5 -0.25
1 0 0
= 0 1 0
0 0 1
Inverse
5. Math
2. Matrices
23
Inverse matrix (2 of 3)
1
-2
2
A
-1
1
0
0
-3
2
inv(A)
0.5 0.5 0.75
-0.5 0.5 0.75
-0.5 -0.5 -0.25
1. Highlight area for answer
2. Type "= MINVERSE(", or use INSERT FUNCTION
3. Highlight area of matrix
4. Type CTL+SHIFT+ENTER
Matrix inverse using Excel
5. Math
2. Matrices
24
Inverse matrix (3 of 3)
(AB)-1 = B-1 A-1
1 -1 0
A= -2 1 -3
2 0 2
1
B= 0
-1
0.5 0.5 0.75
A-1 = -0.5 0.5 0.75
-0.5 -0.5 -0.25
2
B-1 = -1
2
0.5 1
0 -1
0.5 2
-1 -1
0.25 0.75 1.625
4 2 (AB)-1 = 0
0 -0.5
0 1
-0.25 0.35 1.375
0.25 0.75 1.625
0 -0.5
B-1A-1 = 0
-0.25 0.35 1.375
Inverse of a product
5. Math
2. Matrices
25
Orthogonal matrix
An orthogonal matrix is a matrix whose
inverse is equal to its transpose.
1
0
0
5. Math
0
0
cos sin
-sin cos
1
0
0
0
0
1 0 0
cos -sin = 0 1 0
sin cos
0 0 1
2. Matrices
26
Hermetian matrix (1 of 3)
A Hermetian matrix is a matrix that is
equal to its own Hermetian transpose
• A = AH
The Hermetian transpose of A is the
complex conjugate transpose of A
• AH = AT
Hermetian matrix
5. Math
2. Matrices
27
Hermetian matrix (2 of 3)
A=
1
1-I
1+I 3
2
-i
2
i
0
AT =
1
1-I
2
1+I
3
+i
2
-i
0
1
1-I
1+I 3
2
-i
2
i
0
AT =
=A
Example
5. Math
2. Matrices
28
Hermetian matrix (3 of 3)
1
1+i
2
H
1-i
3
i
2
-i
0
H'
1
1+i
1-i
3
2
-i
2
i
0
conj(H')
1
1-i
2
1+i
3
-i
2
i
0
1. Use COMPLEX to enter complex numbers
2. Use IMCONJUGATE to convert cell-by-cell
Note: Cell operations; not matrix
Hermetian matrix using Excel
5. Math
2. Matrices
29
Unitary matrix
A matrix is unitary if its inverse equals its
Hermetian transpose
• U-1 = UH
DFT and inverse DFT are unitary matrices
5. Math
2. Matrices
30
3. Least squares
Example 1
Example 2
5. Math
3. Least squares
31
Example 1 (1 of 9)
x + 2y + 3z = 14
-2x +
+ z= 1
2x + y
= 4
1 2 3
A = -2 0 1
2 1 0
-1 3 2
A-1 = -1/3 2 -6 -7
-2 3 4
x
y
z
= A-1 b =
14
b= 1
4
1
2
3
Solve 3 equations and 3 unknowns
5. Math
3. Least squares
32
Example 1 (2 of 9)
x + 2y + 3z = 14
-2x +
+ z= 1
2x + y
= 4
3x + y - z = 2
x
y
z
=
x + 2y + 3z = 13
-2x +
+ z= 1
2x + y
= 4
3x + y - z = 3
x
y
z
= ?
1
2
3
What happens if we have 4 equations and 3 unknowns
5. Math
3. Least squares
33
Example 1 (3 of 9)
e1
e2
e3
e4
= x + 2y + 3z - 13
= -2x +
+ z- 1
= 2x + y
- 4
= 3x + y - z - 3
Minimize J = (e12 + e22 + e32 + e42)
Minimize the sum of squares
5. Math
3. Least squares
34
Example 1 (4 of 9)
x
y
x
0.46 3.37 1.91
coefficients
1.0 2.0 3.0
-2.0 0.0 1.0
2.0 1.0 0.0
3.0 1.0 -1.0
sum of squares
b
e
e^2
13.0
1.0
4.0
3.0
-0.1
0.0
0.3
-0.2
0.0
0.0
0.1
0.0
0.11
1. Set up matrix as shown
2. Select Solver
3. Select the cell containing the sum of squares
4. Select "minimize"
5. Set "by changing cells" to the unknowns -- x, y, z
6. Select solve
Solve using Solver in Excel
5. Math
3. Least squares
35
Example 1 (5 of 9)
e1
e2
e3
e4
A=
ATA s = AT b
= x + 2y + 3z - 13
= -2x +
+ z- 1
= 2x + y
- 4
= 3x + y - z - 3
1
-2
2
3
2
0
1
1
3
1
0
1
13
b=
1
4
3
s = [ATA]-1 AT b =
x
y
z
0.46
= 3.37
1.91
Solve using matrices
5. Math
3. Least squares
36
Example 1 (6 of 9)
A=
a1x
a2x
a3x
a4x
AT
a1y
a2y
a3y
a4y
a1z
a2z
a3z
a4z
b = b1
b2
b3
b4
a1x a2x a3x a4x
A= a a a a
1y 2y 3y 4y
a1z a2z a3z a4z
=
a1x
a2x
a3x
a4x
AT = a1x a2x a3x a4x
a1y a2y a3y a4y
a1z a2z a3z a4z
a1y
a2y
a3y
a4y
a1z
a2z
a3z
a4z
akx akx aky akx akz akx
akx aky aky aky akz aky
akx akz aky akz akz akz
Express matrix solution in more general terms
5. Math
3. Least squares
37
Example 1 (7 of 9)
AT b =
akxbk
akxbk
akzbk
Express matrix solution in more general terms (cont)
5. Math
3. Least squares
38
Example 1 (8 of 9)
J = [a1xx + a1yy + a1zz - b1]2 +
[a2xx + a2yy + a2zz - b2]2 +
[a3xx + a3yy + a3zz - b3]2 +
[a4xx + a4yy + a4zz - b4]2
J/ x = 2[a1xa1xx + a1ya1xy + a1za1xz - a1xb1] +
[a2xa2xx + a2ya2xy + a2za2xz - a2xb2] +
[a3xa3xx + a3ya3xy + a3za3xz - a3xb3] +
[a4xa4xx + a4ya4xy + a4za4xz - a4xb4]
2[ akx akx x aky akx y akz akxz - akxbk ]
=0
Minimize by calculus
5. Math
3. Least squares
39
Example 1 (9 of 9)
akx akx x aky akx y akz akxz - akxbk = 0
akx aky x aky aky y akz akyz - akybk = 0
akx akz x aky akz y akz akzz - akzbz = 0
akx akx aky akx akz akx
akx aky aky aky akz aky
akx akz aky akz akz akz
x
y
z
-
akxbk
akybk
akzbk
=0
Minimize by calculus (continued)
5. Math
3. Least squares
40
Example 2 (1 of 3)
x=
1.1000
1.9000
2.9000
4.0000
5.0000
6.0000
y=
2.2000
3.0000
4.1000
5.0000
6.1000
6.9000
Fit a curve to the following data
5. Math
3. Least squares
41
Example 2 (2 of 3)
Fit z = a + b xi + c xi2
A = [[1;1;1;1;1;1], x, x.*x] =
b=y
a
b
c
=
(ATA)-1
AT
b =
1.0000 1.1000 1.2100
1.0000 1.9000 3.6100
1.0000 2.9000 8.4100
1.0000 4.0000 16.0000
1.0000 5.0000 25.0000
1.0000 6.0000 36.0000
1.0126
1.0949
-0.0184
Fit curve z to data
5. Math
3. Least squares
42
Example 2 (3 of 3)
error = a + b x + c x2 - y =
7
6.5
6
5.5
5
-0.0052
0.0266
-0.0668
0.0980
-0.0726
0.0200
4.5
4
3.5
3
2.5
2
1
2
3
4
5
6
Error in curve fit
5. Math
3. Least squares
43
4. Propagation of variance
Combining variance
Multiple dimensions
Example -- propagation of position
Example -- angular rotation
5. Math
4. Propagation of variables
44
Combining variances
Variances from multiple error sources can
be combined by adding variances
Example
xorig = standard deviation in original position = 1 m
vorig = standard deviation in original velocity = 0.5 m/s
T = time between samples = 2 sec
xcurrent = error in current position
= square root of [(xorig)2 + (vorig * T)2] = sqrt(2)
5. Math
4. Propagation of variables
45
Multiple dimensions
When multiple dimensions are included,
covariance matrices can be added
P1 = covariance of error source 1
P2 = covariance of error source 2
P = resulting covariance = P1 + P2
When an error source goes through a
linear transformation, resulting covariance
is expressed as follows
T = linear transformation
TT = transform of linear transformation
Porig = covariance of original error source
P = T * P * TT
5. Math
4. Propagation of variables
46
Example -- propagation of position
xorig = standard deviation in original position = 2 m
vorig = standard deviation in original velocity = 0.5
m/s
T = time between samples = 4 sec
xcurrent = error in current position
xcurrent = xorig + T * vorig
vcurrent = vorig
T= 1 4
0 1
Porig =
Pcurrent = T * P orig * TT =
5. Math
1
0
4
1
22 0
0 0.52
4
0
0
0.25
4. Propagation of variables
1
4
0
1
= 16 4
4 0.25
47
Example -- angular rotation
Xoriginal = original coordinates
Xcurrent = current coordinates
T = transformation corresponding to angular rotation
y
y’
T = cos -sin
where = atan(0.75)
sin cos
Porig =
5. Math
x
1.64 -0.48
-0.48 1.36
Pcurrent = T * P orig * TT =
x’
0.8 -0.6
0.6 0.8
1.64 -0.48
-0.48 1.36
5. Statistics
0.8 0.6
-0.6 0.8
= 2
0
0
1
48
5. Geometry
Unit vectors
Angle between two lines
Perpendicular to a plane
Pointing
5. Math
5. Geometry
49
Unit vectors
A unit vector is a vector of length 1.
Unit vectors are frequently used to denote
vectors that have the same direction, such
as those parallel to a chosen axis of a
coordinate system
5. Math
5. Geometry
50
Angle between two lines (1 of 10)
The dot product is the result of multiplying
the length of a vector A times the length of the
component of vector B that is parallel to A
A • B = |A| |B| cos , where is the angle
between the vectors
Dot product
5. Math
5. Geometry
51
Angle between two lines (2 of 10)
To find the angle between two lines,
• Establish a vector A and a vector B
along each line
• Solve for = arccos[A • B /( |A| |B| )]
• 0
Solving for using dot product
5. Math
5. Geometry
52
Angle between two lines (3 of 10)
A = [1 2], B = [2 1]
|A| = SQRT(12 + 22) = SQRT(5)
|B| = SQRT(22 + 12) = SQRT(5)
A • B = [1 2] • [2 1]T = [2 • 1 + 2 • 1] = 4
4 = SQRT(5) • SQRT(5) cos
cos = 4/5
y
A
B
x
Example using dot product
5. Math
5. Geometry
53
Angle between two lines (4 of 10)
A
1
2
B
2
1
A'
1
2
B'
2
1
A'*A B'*B A'*B
5
5
4
2.24 2.24
1. Use dot product to compute square of hypotenuse
angle(radians)
0.64
angle(degrees) = angle (radians)*180/pi
36.9
1. Use ACOS to compute angle in radians
2. Use 180/pi to convert angle to degrees
3. Use PI function to compute pi
Note: PI must be followed by "(" if typed
Using Excel to compute values
5. Math
5. Geometry
54
Angle between two lines (5 of 10)
The cross product is the result of
multiplying the length of a vector A times
the length of the component of vector B
that is perpendicular to A
A x B = |A| |B|sin , where is the angle
between the vectors
The vector A x B is perpendicular to the
plane containing A and B
Cross product
5. Math
5. Geometry
55
Angle between two lines (6 of 10)
To find the angle between two lines,
• Establish a vector A and a vector B
along each line
• Solve for = arcsin[A x B /( |A| |B| )]
• - /2 /2
Solving for using cross product
5. Math
5. Geometry
56
Angle between two lines (7 of 10)
A=
=
i
j
k
Ax Ay Az
Bx By Bz
i
1
2
j
2
1
k
0
0
= -3k
Example using cross product
5. Math
5. Geometry
57
Angle between two lines (8 of 10)
A = [1 2], B = [2 1]
|A| = SQRT(12 + 22) = SQRT(5)
|B| = SQRT(22 + 12) = SQRT(5)
A x B = -3 k
-3 = SQRT(5) • SQRT(5) sin
sin = -3/5
Example using cross product (continued)
5. Math
5. Geometry
58
Angle between two lines (9 of 10)
= atan2(sin , cos )
Combining dot product and cross product
5. Math
5. Geometry
59
Angle between two lines (10 of 10)
x
-0.6
y
-0.8
ATAN
53.13
ATAN2
-127
1. Use ATAN2 for four quadrant arctangent
Note: First argument is X and not Y as in FORTRAN
Using Excel to compute arctangents
5. Math
5. Geometry
60
Perpendicular to a plane
The cross product defines the direction
perpendicular to the plane defined by the
two vectors A and B
5. Math
5. Geometry
61
Pointing (1 of 14)
y0
B (2,3,2)
A (3,1,1)
camera
x0
Change pointing of camera so that points A and
B are on the same level
Point camera as directed
5. Math
5. Geometry
62
Pointing (2 of 14)
y1
y0
B (2,3,2)
x1
A (3,1,1)
x0
z0 and z1 are positive out of page
Pan camera to point at A in the x0-y0 plane
5. Math
5. Geometry
63
Pointing (3 of 14)
T01
= atan2(3,1) = 18.4o
cos sin 0
-sin cos 0
0
0
1
3
1
1
cos sin 0
-sin cos 0
0
0
1
2
3
2
=
=
3.16
0.00
1.00
2.85
2.22
2.00
Determine T01 as follows
5. Math
5. Geometry
64
Pointing (4 of 14)
y1
z1 is positive out of page
B (2.85,2.22,2)
camera
x1
A (3.16,0,1)
Redraw problem in x1-y1
5. Math
5. Geometry
65
Pointing (5 of 14)
z1
y1 is positive into page
B (2.85,2.22,2)
A (3.16,0,1)
camera
x1
View x1-z1 plane
5. Math
5. Geometry
66
Pointing (6 of 14)
z1
z2
y1 and y2 are positive into page
B (2.85,2.22,2)
x2
A (3.16,0,1)
x1
Elevate camera to point at A in x1-z1 plane
5. Math
5. Geometry
67
Pointing (7 of 14)
T12
= atan2(1,3.16) = 17.5o
cos 0
0
1
-sin 0
sin
0
cos
3.16
0.00 =
1.00
3.16
0.00
0.00
cos 0
0
1
-sin 0
sin
0
cos
2.85
2.22 =
2.00
3.32
2.21
1.05
Determine T12 as follows
5. Math
5. Geometry
68
Pointing (8 of 14)
x2 is positive into page
z2
B (3.32,2.21,1.05)
y2
A (3.16,0,0)
View y2-z2 plane
5. Math
5. Geometry
69
Pointing (9 of 14)
z2
z3
y3
B (3.32,2.21,1.05)
y2
A (3.16,0,0)
x2 and x3 are positive into page
Roll camera so that A and B are on horizontal line
5. Math
5. Geometry
70
Pointing (10 of 14)
= atan2(1.05.2.21) = 25.4o
T23
1
0
0
0 cos sin
0 -sin cos
3.32
2.21 =
1.05
3.32
2.45
0.00
Determine T23 as follows
5. Math
5. Geometry
71
Pointing (11 of 14)
x3 is positive into page
y3
z3
A (3.16,0,0)
B (3.32,2.45,0)
View y3-z3 plane
5. Math
5. Geometry
72
Pointing (12 of 14)
T01T T12T T23T
0
0
1
=
-0.12
-0.49
0.86
Express unit vector perpendicular to AB in x0-y0-z0 plane
5. Math
5. Geometry
73
Pointing (13 of 14)
A=
=
i
j
k
Ax Ay Az
Bx By Bz
i
3
2
j
1
3
k
1
2
= (- i - 4j +7k)/sqrt(66)
=
-0.12
-0.49
0.86
Compare perpendicular unit vector to cross product
5. Math
5. Geometry
74
Pointing (14 of 14)
T01, T12, T23, and any of their products
are examples of direction cosine matrices
The element in aij is the cosine between
axis i and axis j
Define direction cosine matrix
5. Math
5. Geometry
75