## DBsubject(Linear algebra) ## DBchapter(Abstract vector spaces) ## DBsection(Span) ## Date(10/5/2013) ## Institution(NAU) ## Author(Nandor Sieben) ## RevisedBy('Sean Fitzpatrick') ## Level(2) ## MO(1) ## KEYWORDS('linear algebra','span') DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "MatrixReduce.pl", "PGcourse.pl", "PGML.pl", "PCCmacros.pl" ); $showPartialCorrectAnswers = 1; TEXT(beginproblem()); Context("Fraction"); Context() -> parens -> set ("[" => {formMatrix => 1}); ## include rank algorithm from rank.pl file 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); } Context() -> normalStrings; $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\} .```] 1. Find a nonzero element [`X`] in [` W `]. [__________]{$A1} 2. Find an element [`Y`] in [` V `] that is not in [` W `]. [__________]{$A2} [@KeyboardInstructions('Enter your matrices using the syntax [|[[a,b],[c,d]]|].')@]** END_PGML ENDDOCUMENT();