ALA K+Kf+Bt, part a, fall 2002

Program

1. After you have done exercise   14,  15   and   16   from yesterday, with   A = [1 2; 3 4]  say, try   inv(A).  What does  inv(A)   do?

2. Recall that in exercise   14   we could compute  X  because   A(1, 1) A(2, 2) - A(1, 2) A(2, 1),  appearing in the denominator, was non zero. Also, in exercise   16   we could solve for both   x1  and   x2   because the columns of   A   were "independent", that is non parallel in this case. The number   A(1, 1) A(2, 2) - A(1, 2) A(2, 1)  associated with  A  is called the "determinant of  A",  because it "determinates" if  A  has an inverse matrix or not. Thus  A  has an inverse matrix if the determinant is non-zero, otherwise not. The determinant of  A  is denoted  det(A),  and matlab has a function with the same name for computing it. Try it, and compare  det(A)  to  A(1, 1)*A(2, 2) - A(1, 2)*A(2, 1).  There are corrsponding (more complicated formulas) for   3 x 3  matrices and, more generally, for  n x n  matrices which we will meet later. Note also, that for a  2 x 2  matrix,  det(A)   coinsides with the vector product of the column vectors of  A,  which if equal to zero indicates that the columns are parallel in which case there is no inverse matrix. Try  det(C)  and   inv(C)   for   C = [1 2; 3 6]   for example, and note that the vector product   [1 3] x [2 6]   of the columns   [ 1; 3]   and   [ 2; 6]   of   C   equals   0   (check this!)

3. Find   m   and   k   such that the line   y = m + kx   passes through two given points   ( x1, y1)   and   ( x2, y2).   Consider first a specific case if you like, for example the points   ( 1, 4)   and   ( 3, -2),  which gives two linear equations for   m   and   k,  namely   m + k = 4   and   m + 3k = -2.   Why? Solve this system of equations by hand, and then using matlab. To use matlab you must form the corresponding matrix   [ 1 1; 1 3]   and (target) vector   [ 4; -2],  of course. Understand why, and how to compute   m   and   k   this way!!
Test your formulas for obtaing   m   and   k   by plotting the resulting line, by first defining a suitable list/vector   x   of   x -  coordinates, and then writing   plot( x, m + k*x)   with the   m   and   k   you found. Check that the plotted line passes the given points. Note that to plot a line the list   x   need only contain two   x -  coordinates, corresponding to the endpoints of the desired plot interval.

4. Consider a given function, for example   f(x) = 2x^3 - x,  and plot (part of) its associated graph   y = f(x)   by defining   x = [ -1 : .1 : 2]  and using   plot( x, 2*x.^3 - x).  Then find the line that "interpolates"   f(x),  that is, takes the same valus as   f(x),  for   x = .5   and   x = 1.  Plot the corrsponding linear function together with   y = f(x)   by first writing hold on, and then   plot( x, m + k*x, 'r')   with the   m   and   k   you computed from the corresponding values of   f(x)   at the given interpolation points. You should now see both the graph   y = f(x),   in blue, and the "linear approximation" of   y = f(x)   defined by the interpolating secant, in red.

5. Extend your Bisection solver so that it computes not only a final interval   [ a b]   containing a root (zero of   f(x) ), but also the root of the corresponding "linearized problem" obtained by replacing   y = f(x)   by the secant through   ( a, f(a))   and   ( b, f(b)),  that is the   x   at which the linear secant approximating   y = f(x)   has zero   y -  value, that is, intersects the   x -  axis.

6. Important: Make sure you understand the representation   y = m + k (x - a)   of a line through the point   ( a, m)   with slope   k.  Go back to the Graph gallery of   RMplus,  and the exibition of linear relations. Choose relation of the given form and vary the parameters   am   and   k

/Kenneth


Last modified: