DOCUMENT(); loadMacros( 'PGstandard.pl', 'MathObjects.pl', 'PGML.pl', 'contextFraction.pl', 'MatrixReduce.pl', 'PGcourse.pl' ); $showPartialCorrectAnswers = 1; TEXT(beginproblem()); Context('Fraction'); Context()->parens->set('[' => { formMatrix => 1 }); sub rank { my $R = rref(apply_fraction_to_matrix_entries(shift)); my ($row, $col) = $R->dimensions; my ($r, $c) = (1, 1); while (($r <= $row) && ($c <= $col)) { $r++ if ($R->element($r, $c) > 0.5); $c++; } $r - 1; } { $a11 = random(-5, 5, 1); $a12 = random(-5, 5, 1); $a22 = random(-5, 5, 1); $b11 = random(-5, 5, 1); $b12 = random(-5, 5, 1); $b22 = random(-5, 5, 1); Context()->parens->set('[' => { formMatrix => 1 }); $A = Matrix([ [ $a11, $a12 ], [ $a12, $a22 ] ]); $B = Matrix([ [ $b11, $b12 ], [ $b12, $b22 ] ]); redo if (rank(Matrix([ [ $a11, $a12, $a22 ], [ $b11, $b12, $b22 ], [ 0, 0, 0 ] ])) < 2); } $answer = $A + $B; $answer = $A - $B if (rank($answer) == 0); { $c1 = Compute(random(-2, 2, 1)); $c2 = Compute(random(-2, 2, 1)); $c3 = Compute(1); Context()->parens->set('[' => { formMatrix => 1 }); $answer2 = Matrix([ [ $c1, $c3 ], [ $c3, $c2 ] ]); redo if ( rank(Matrix( [ $a11, $a12, $a22 ], [ $b11, $b12, $b22 ], [ $answer2->element(1, 1), $answer2->element(1, 2), $answer2->element(2, 2) ] )) == 2 ); } $A1 = $answer->cmp( checker => sub { my ($correct, $student, $ansHash) = @_; if (!$student->is_symmetric) { return 0; } if (rank(Matrix($student)) == 0) { return 0; } if ( rank(Matrix( [ $a11, $a12, $a22 ], [ $b11, $b12, $b22 ], [ $student->element(1, 1), $student->element(1, 2), $student->element(2, 2) ] )) == 2 ) { return 1; } return 0; } ); $A2 = $answer2->cmp( checker => sub { my ($correct, $student, $ansHash) = @_; if (!$student->is_symmetric) { return 0; } if ( rank(Matrix( [ $a11, $a12, $a22 ], [ $b11, $b12, $b22 ], [ $student->element(1, 1), $student->element(1, 2), $student->element(2, 2) ] )) == 3 ) { return 1; } return 0; } ); BEGIN_PGML Let [`V`] be the vector space of symmetric [`2\times 2`] matrices and [`W`] be the subspace [```W=\operatorname{span} \left\{ [$A],[$B] \right\} .```] a. Find a nonzero element [`X`] in [` W `]. [` X =`] [@ $answer->ans_array @]* b. Find an element [`Y`] in [` V `] that is not in [` W `]. [` Y = `] [@ $answer2->ans_array @]* END_PGML ANS($A1); ANS($A2); ENDDOCUMENT();