## DESCRIPTION ## Linear Algebra ## ENDDESCRIPTION ## KEYWORDS('Quadratic form' 'Decomposition of Symmetric Matrix') ## Tagged by tda2d ## DBsubject('Linear Algebra') ## DBchapter('Matrices') ## DBsection('Quadratic Forms') ## Date('') ## Author('Shifrin') ## Institution('UGA') ## TitleText1('') ## EditionText1('') ## AuthorText1('') ## Section1('') ## Problem1('') DOCUMENT(); # This should be the first executable line in the problem. loadMacros( "PG.pl", "PGbasicmacros.pl", "PGchoicemacros.pl", "PGanswermacros.pl", "PGauxiliaryFunctions.pl", "PGgraphmacros.pl", "PGmatrixmacros.pl", # "PGmorematrixmacros.pl" "weightedGrader.pl" ); TEXT(beginproblem()); install_weighted_grader(); $showPartialCorrectAnswers = 1;$L = new Matrix(2,2); $D = new Matrix(2,2);$LT = new Matrix(2,2); $A = new Matrix(2,2);$d11 = non_zero_random(-5,5,1); $d22 = random(-5,5,1);$l21 = random(-5,5,1); $D->assign(1,1,$d11); $D->assign(2,2,$d22); $L->assign(2,1,$l21); $LT->assign(1,2,$l21); foreach $i (1..2){ foreach$j (1..2){ if($j!=$i) { $D->assign($i,$j,0);}}} foreach$i (1..2){ foreach $j (1..2){ if($j==$i) {$L->assign($i,$j,1); $LT->assign($i,$j,1);} elsif($j>$i){$L->assign($i,$j,0); $LT->assign($j,$i,0);}}}$A = $L*$D*$LT;$ques=("The quadratic form $$\mathcal Q(\mathbf x) = \mathbf x^T A \mathbf x$$ is"); if($d11>0 and$d22>0){$ans="positive definite";} elsif(($d11==0 and $d22>=0) or ($d11>0 and $d22==0)){$ans="positive semidefinite";} elsif($d11<0 and$d22<0){$ans="negative definite";} elsif(($d11==0 and $d22 le 0) or ($d11<0 and $d22==0)){$ans="negative semidefinite";} else {$ans="indefinite";}$mc0 = new_multiple_choice(); $mc0->qa($ques, $ans);$mc0->makeLast("positive definite","negative definite","positive semidefinite", "negative semidefinite","indefinite"); BEGIN_TEXT If $$A=\{display_matrix_mm(A)\}$$, $BR then we can write $$A = LDL^T$$, where$PAR \{mbox( '$$L =$$', display_matrix([['$$1$$','$$0$$'],[ans_rule(5),'$$1$$']]) )\} $BR \{mbox('and', '$$D =$$', display_matrix([[ans_rule(5),'$$0$$'],['$$0$$',ans_rule(5)]]), '.')\}$PAR \{ $mc0->print_q() \} \{$mc0->print_a() \} END_TEXT WEIGHTED_ANS(num_cmp($l21),25, num_cmp($d11),25, num_cmp($d22),25, radio_cmp($mc0->correct_ans),25); ENDDOCUMENT(); # This should be the last executable line in the problem. ANS(num_cmp ra_flatten_matrix($C*$B));