[npl] / branches / UGA / 5.5.3.pg Repository:
ViewVC logotype

View of /branches/UGA/5.5.3.pg

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1457 - (download) (annotate)
Sat Jul 24 17:09:50 2010 UTC (2 years, 10 months ago) by ted shifrin
File size: 2009 byte(s)
Log message

    1 ## DESCRIPTION
    2 ## Linear Algebra
    3 ## ENDDESCRIPTION
    4 
    5 ## KEYWORDS ('linear algebra','linear system','least squares','inner product')
    6 ## Tagged by cmd6a 5/3/06
    7 
    8 ## DBsubject('Linear Algebra')
    9 ## DBchapter('Systems of Linear Equations and Matrices')
   10 ## DBsection('Least Squares')
   11 ## Date('')
   12 ## Author('modified by Shifrin')
   13 ## Institution('UGA')
   14 ## TitleText1('')
   15 ## EditionText1('')
   16 ## AuthorText1('')
   17 ## Section1('')
   18 ## Problem1('')
   19 
   20 DOCUMENT();        # This should be the first executable line in the problem.
   21 
   22 loadMacros(
   23 "PG.pl",
   24 "PGbasicmacros.pl",
   25 "PGchoicemacros.pl",
   26 "PGanswermacros.pl",
   27 "PGgraphmacros.pl",
   28 "PGmatrixmacros.pl",
   29 "PGnumericalmacros.pl",
   30 "PGauxiliaryFunctions.pl"
   31 );
   32 
   33 TEXT(beginproblem());
   34 $showPartialCorrectAnswers = 1;
   35 
   36 # we choose the matrix A, solution x, and a vector c orthogonal to the columns of A.
   37 # we set b=Ax+c, then x is the least-squares solution of Ax=b.
   38 
   39 $a11 = random(1,2,1);
   40 $a12 = random(-2,-1,1);
   41 $a21 = - $a11;
   42 $a22 = - $a12;
   43 $a31 = random(3,5,1);
   44 $a32 = random(3,5,1);
   45 
   46 $x1 = non_zero_random(-5,5,1);
   47 $x2 = random(-5,5,1);
   48 
   49 $c1 = non_zero_random(-6,6,1);
   50 $c2 = $c1;
   51 $c3 = 0;
   52 
   53 $b1 = $a11*$x1 + $a12*$x2 + $c1;
   54 $b2 = $a21*$x1 + $a22*$x2 + $c2;
   55 $b3 = $a31*$x1 + $a32*$x2 + $c3;
   56 
   57 BEGIN_TEXT
   58 
   59 Find the least-squares solution \(\overline{\mathbf x}\) of the system
   60 $PAR
   61 \( \{display_matrix_mm([[$a11, $a12], [$a21, $a22], [$a31, $a32]])\}\mathbf x=
   62    \{display_matrix_mm([[$b1], [$b2], [$b3]])\} \) .
   63 $BR
   64 \{ mbox( '\(\overline{\mathbf x} = \)', answer_matrix(2,1,5), '.' ) \}
   65 
   66 $PAR
   67 Use your answer to find the point on the plane spanned by
   68 \(\{display_matrix_mm([[$a11],[$a21],[$a31]])\}\)  and \(\{display_matrix_mm([[$a12],[$a22],[$a32]])\} \)  that is closest to \( \{display_matrix_mm([[$b1], [$b2], [$b3]])\} \) .
   69 $BR
   70 \{ answer_matrix(3,1,8) \}
   71 $BR
   72 
   73 
   74 END_TEXT
   75 
   76 ANS(num_cmp($x1));
   77 ANS(num_cmp($x2));
   78 ANS(num_cmp($a11*$x1 + $a12*$x2),num_cmp($a21*$x1 + $a22*$x2),num_cmp($b3));
   79 
   80 ENDDOCUMENT();       # This should be the last executable line in the problem.
   81 

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9