Dan Witzner Hansen Email : [email protected] Linear algbra. Last week?. Groups? Improvements – what is missing?. Misc. The goal is to be able to solve linear equations Continue with linear algebra Linear mappings Basis vectors & independence Solving linear equations & Determinants
Improvements – what is missing?Misc
anxn+ an-1xn-1+ . . . + a1x1 = b.
a1,1x1+ a1,2x2+ . . . + a1,nxn = b1
a2,1x1+ a2,2x2+ . . . + a2,nxn = b2
. . .
am,1x1+ am,2x2+ . . . + am,nxn = bm
Compact notation Ax=b
Species 2: eats 2 units of A and 4 of B.
Everyday a total of 900 units of A and 960 units of B are eaten. How many animals of each species are there?Example
A = [5 2; 3 4];
b = [900 960];
x = linspace(0,150,100);
y1 = (-A(1,1)*x+b(1))/A(1,2); %made for clarity
y2 = (-A(2,1)*x+b(2))/A(2,2);
Plot(x,y1,'r-','LineWidth',3); hold on
Plot(x,y2,'b-','LineWidth',3); hold off
title('Linear equations and their solution')
Basis vectors / Orthonomal basisAn now for some formalism
A subspaceis a vector space contained in another vector spaceSubspaces
Can it happen that y=0 if x is nonzero?
Change of basis
A = [1 4 2;2 8 6; 3 124];
[X,Y,Z] = meshgrid(-10:10,-10:10,-10:10);
x = [X(:),Y(:),Z(:)]’;
p = A*x;
A solution to a system of equations is simply an assignment of values to the variables that satisfies (is a solution to) all of the equations in the system.
If a system of equations has at least one solution, we say it is consistent.
If a system does not have any solutions we say that it is inconsistent.Solutions of linear equations
Can we always do this?
How many solutions are there?
What to do when the dimension and the number of data points is large?
How many data points are needed to solve for the unknown parameters in x?What if?
A (unique) inverse exist if det(A) ≠ 0 (NxN matrices)
Matlab: >>invA =inv(A)Matrix Inverse
Don’tuse for solvingthe linear system. It is mostlymeant for notationalconvenience.
It is faster and more accurate (numerically) to write (solve)x=A\bthaninv(A)*b:Notice: implementation
Orthogonal matricesSimple inversion of (some) matrices
With more than two points, there is no guarantee that they will all be on the same lineFitting Lines
Find the vector Fx in the column range of F, which is closest to the right-hand side vector y.
The residual r=y-Fx
Solution: Use the pseudoinverse
A+ =(ATA)-1AT to obtain least-squares solutionx=A+b
and x=A+b=(0.3571, 0.2857)TExample: Fitting a Line
(2, 1), (5, 2), (7, 3), and (8, 3)
Tells how close to singular A is.
Inverse and pseudoinverse
The columns of U corresponding to nonzeros singular values span the range of A, the columns of V corresponding to zero singular values the nullspace.Properties of SVD
A 2-D homogeneous point x = (x, y, 1)T is on the line l = (a, b, c)T only when
ax+ by + c = 0
We can write this equation with a dot product:
x.l= 0,and hence the following system is implied for multiple points x1, x2, ..., xn:
Again we have 4 points, but now in homogeneous form:
(2, 1, 1), (5, 2, 1), (7, 3, 1), and (8, 3, 1)
compare tox =(0.3571, 0.2857)T