a=[1; 2; 3; 4], b=[4; 3; 2; 1], c=2*a-3*b, A=[a b c], B=[a b]
Remember that u=[1;1;1;0] does not belong to V=R(A). We will compute the projection Pu of u onto V. Remember that a,b, but not a,b,c, are linearly independent, so a,b is a basis for V and V=R(A)=span(a,b,c)=R(B)=span(a,b). Pu belongs to V, so it is a linear combination of a,b, i.e.,
Pu=Bx=x1a+x2b.
We will determine the coefficients x1, x2, so that the residual u-Pu is orthogonal to V. This means that
(u-Pu,v)=0 for all v in V.
Since a,b is a basis for V, it is sufficient to take v=a and v=b here:
(u-Pu,a)=0
or equivalently
(Pu,a)=(u,a)
(u-Pu,b)=0
(Pu,b)=(u,b)
If we insert Pu=x1a+x2b here we get a system of two equations:
x1(a,a) + x2(b,a) = (u,a)
x1(a,b) + x2(b,b) = (u,b)
Insert the given vectors a,b,u and solve for the coefficients
x1, x2. Hint: the matrix of the
system is
C=[a'*a a'*b; b'*a b'*b].
What is the vector of the right hand side?
Form the vector v=Pu and check that w=u-Pu is orthogonal to a, b, c, and Pu as required. This illustrates the proof of Theorem 41.8.
2. Orthogonal decomposition, see Ch 41.34.
We have an orthogonal decomposition of the space Rn
so that every vector u can be written
u = Pu + (u-Pu) = v + w,
where v=Pu belongs to V and w=u-Pu is orthogonal to V.
Show that
|| u ||2 = || Pu ||2 + || u-Pu ||2
.
(Pythagoras' theorem)
Hint: expand the square || v+w ||2 = (v+w,v+w) and use orthogonality.
Check that this equality holds for the vectors v, w that you computed earlier.
3. The least squares method, Ch 41.42. We recall that the vector u does not belong to R(B), so that the equation Bx=u has no solution. It is therefore impossible to make the residual Bx-u equal to 0, and we try instead to minimize the norm of the residual:
find x in R2 such that || Bx-u ||2 is minimized.
The is called "the least squares method". We know that the distance || Bx-u || is minimal when Bx is the projection of u onto V=R(B)=span(a,b), which is exactly what we computed in exercise 1. So we have just computed the least squares solution x. Now we will do it again in a different way.
Pu is determined by the equation
(u-Pu,v)=0 for all v in V=R(B)
Here we have Pu=Bx and v=By for some x,y in R2. Hence, we want to find x in R2 such that
(u-Bx,By)=0 for all y in R2.
Here (u-Bx,By)=(BTu-BTBx,y) so that (BTu-BTBx,y)=0 for all y in R2. This implies that
(*) BTBx=BTu (the normal equations)
Here we used the fact that (w,y)=0 for all y, implies w=0. Prove this! Hint: we can take y=w because the equality should hold for all y.
Prove that BTB is symmetric.
Set up the normal equations with the given matrices B, u and solve the equations. Compare with what you got in exercise 1. In matlab the backslash operator: x=B\u gives the least squares solution if the equation Bx=u has no solution.
4. (Advanced) The tank reactor. The Arrhenius rate law is k=k0 exp(-E/(RT)). The task is to determine the rate constant k0 and the activation energy E from the given information. Form the logarithm of this equation to get at linear relation between y=log(k) and x=1/T, y=b+ax. Use the given information about the reaction rate to generate several (5 or 10) data points Ti, ki. (Remember that T is the absolute temperature [K].) Then set up a linear system of equations and solve them by the least squares method. The idea is that we determine the coefficients a, b by finding a straight line y=b+ax that fits the given data points as well as possible, i.e., find a,b so that the norm of the residual b+axi-yi is minimized.
Hint: B=[ones(5,1) -1./T]. The result should be somewhere around k0=1e8, E=8e4.
/stig