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

View of /branches/UGA/9.4.6.pg

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1458 - (download) (annotate)
Sat Jul 24 17:11:33 2010 UTC (2 years, 9 months ago) by ted shifrin
File size: 2718 byte(s)
Log message

    1 ## DESCRIPTION
    2 ## Linear Algebra
    3 ## ENDDESCRIPTION
    4 
    5 ## KEYWORDS ('linear algebra','matrix','symmetric','eigenvalue','eigenvector')
    6 ## Tagged by cmd6a 5/3/06
    7 
    8 ## DBsubject('Linear Algebra')
    9 ## DBchapter('Matrices')
   10 ## DBsection('Eigenvalues')
   11 ## Date('')
   12 ## Author('modified by Shifrin')
   13 ## Institution('Rochester')
   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 "PGmorematrixmacros.pl"
   32 );
   33 
   34 TEXT(beginproblem());
   35 $showPartialCorrectAnswers = 1;
   36 
   37 # orthogonal matrix:
   38 
   39 $a[1][1] = 1/sqrt(3);  $a[1][2] = -2/sqrt(6);  $a[1][3] = 0;
   40 $a[2][1] = 1/sqrt(3);  $a[2][2] = 1/sqrt(6);   $a[2][3] = 1/sqrt(2);
   41 $a[3][1] = 1/sqrt(3);  $a[3][2] = 1/sqrt(6);   $a[3][3] = -1/sqrt(2);
   42 
   43 $U = new Matrix(3,3);
   44 
   45 # slice columns and rows:
   46 
   47 @slice1 = NchooseK(3,3);
   48 @slice2 = NchooseK(3,3);
   49 
   50 foreach $i (1..3) {
   51   foreach $j (1..3) {
   52     $u[$i][$j] = $a[$slice1[$i-1]+1][$slice2[$j-1]+1];
   53     $U -> assign($i,$j,$u[$i][$j]);
   54   }
   55 }
   56 
   57 if ($slice2[0]==0) { $eig1 = random(-9,-3,3); }
   58 if ($slice2[0]==1) { $eig1 = -6; }
   59 if ($slice2[0]==2) { $eig1 = random(-8,-2,2); }
   60 
   61 $eig2 = 0;
   62 
   63 if ($slice2[2]==0) { $eig3 = random(3,9,3); }
   64 if ($slice2[2]==1) { $eig3 = 6; }
   65 if ($slice2[2]==2) { $eig3 = random(2,8,2); }
   66 
   67 $E = new Matrix(3,3);
   68 
   69 foreach $i (1..3) {
   70         foreach $j (1..3) {
   71   $E -> assign($i,$j,0);
   72   }
   73 }
   74 
   75 $E -> assign(1,1,$eig1);
   76 $E -> assign(2,2,$eig2);
   77 $E -> assign(3,3,$eig3);
   78 
   79 $U_lr = $U->decompose_LR();
   80 $I = $U_lr->invert_LR();
   81 
   82 $M = $U * $E * $I;
   83 
   84 BEGIN_TEXT
   85 
   86 Find the eigenvalues \(\lambda_1 < \lambda_2 < \lambda_3 \) and associated unit eigenvectors of the (symmetric) matrix
   87 $BR
   88 \( A =  \{display_matrix_mm($M)\} \).
   89 $PAR
   90 \{ mbox( '\(\lambda_1 \) = ', ans_rule(10) , ',' ) \}
   91 $BR
   92 \{mbox( 'associated unit eigenvector = ', ans_array(3,1,10), ',' ) \}
   93 $BR
   94 \{ mbox( '\(\lambda_2 \) = ', ans_rule(10), ',' ) \}
   95 $BR
   96 \{mbox( 'associated unit eigenvector = ', ans_array(3,1,10), ',' ) \}
   97 $BR
   98 \{ mbox( '\(\lambda_3 \) = ', ans_rule(10), ',' ) \}
   99 $BR
  100 \{mbox( 'associated unit eigenvector = ', ans_array(3,1,10), '.' ) \}
  101 $BR
  102 
  103 
  104 END_TEXT
  105 
  106 ANS(num_cmp($eig1));
  107 ANS(basis_cmp([[$u[1][1], $u[2][1], $u[3][1]]], 'mode'=>'unit', 'help'=>'verbose'));
  108 ANS(num_cmp($eig2));
  109 ANS(basis_cmp([[$u[1][2], $u[2][2], $u[3][2]]], 'mode'=>'unit', 'help'=>'verbose'));
  110 ANS(num_cmp($eig3));
  111 ANS(basis_cmp([[$u[1][3], $u[2][3], $u[3][3]]], 'mode'=>'unit', 'help'=>'verbose'));
  112 
  113 ENDDOCUMENT();       # This should be the last executable line in the problem.
  114 

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9