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

View of /branches/UGA/5.3.1.pg

Parent Directory Parent Directory | Revision Log Revision Log


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

    1 ## DESCRIPTION
    2 ## Linear Algebra
    3 ## ENDDESCRIPTION
    4 
    5 ## KEYWORDS('Quadratic form' 'Decomposition of Symmetric Matrix')
    6 ## Tagged by tda2d
    7 
    8 ## DBsubject('Linear Algebra')
    9 ## DBchapter('Matrices')
   10 ## DBsection('Quadratic Forms')
   11 ## Date('')
   12 ## Author('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 "PGauxiliaryFunctions.pl",
   28 "PGgraphmacros.pl",
   29 "PGmatrixmacros.pl",
   30 # "PGmorematrixmacros.pl"
   31 "weightedGrader.pl"
   32 );
   33 
   34 
   35 
   36 TEXT(beginproblem());
   37 install_weighted_grader();
   38 $showPartialCorrectAnswers = 1;
   39 
   40 $L = new Matrix(2,2);
   41 $D = new Matrix(2,2);
   42 $LT = new Matrix(2,2);
   43 $A = new Matrix(2,2);
   44 
   45 $d11 = non_zero_random(-5,5,1);
   46 $d22 = random(-5,5,1);
   47 $l21 = random(-5,5,1);
   48 
   49 $D->assign(1,1,$d11);
   50 $D->assign(2,2,$d22);
   51 $L->assign(2,1,$l21);
   52 $LT->assign(1,2,$l21);
   53 
   54 foreach $i (1..2){
   55 foreach $j (1..2){
   56 if($j!=$i) {
   57 $D->assign($i,$j,0);}}}
   58 
   59 foreach $i (1..2){
   60 foreach $j (1..2){
   61 if($j==$i) {
   62 $L->assign($i,$j,1); $LT->assign($i,$j,1);} elsif($j>$i){
   63 $L->assign($i,$j,0); $LT->assign($j,$i,0);}}}
   64 
   65 $A = $L*$D*$LT;
   66 
   67 $ques=("The quadratic form \( \mathcal Q(\mathbf x) = \mathbf x^T A \mathbf x \) is");
   68 
   69 if($d11>0 and $d22>0){$ans="positive definite";}
   70 elsif(($d11==0 and $d22>=0) or ($d11>0 and $d22==0)){$ans="positive semidefinite";}
   71 elsif($d11<0 and $d22<0){$ans="negative definite";}
   72 elsif(($d11==0 and $d22 le 0) or ($d11<0 and $d22==0)){$ans="negative semidefinite";}
   73 else {$ans="indefinite";}
   74 
   75 $mc0 = new_multiple_choice();
   76 $mc0->qa($ques, $ans);
   77 $mc0->makeLast("positive definite","negative definite","positive semidefinite", "negative semidefinite","indefinite");
   78 
   79 BEGIN_TEXT
   80 
   81 If \(A=\{display_matrix_mm($A)\}\),
   82 $BR
   83 then we can write \( A = LDL^T \), where
   84 $PAR
   85 \{mbox( '\(L = \)', display_matrix([['\(1\)','\(0\)'],[ans_rule(5),'\(1\)']]) )\}
   86 $BR
   87 \{mbox('and', '\( D = \)', display_matrix([[ans_rule(5),'\(0\)'],['\(0\)',ans_rule(5)]]), '.')\}
   88 $PAR
   89 
   90 \{ $mc0->print_q() \}
   91 \{ $mc0->print_a() \}
   92 
   93 END_TEXT
   94 
   95 WEIGHTED_ANS(num_cmp($l21),25,
   96 num_cmp($d11),25,
   97 num_cmp($d22),25,
   98 radio_cmp($mc0->correct_ans),25);
   99 
  100 ENDDOCUMENT();       # This should be the last executable line in the problem.
  101 
  102 ANS(num_cmp ra_flatten_matrix($C*$B));

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9