## DESCRIPTION ## Linear Algebra ## ENDDESCRIPTION ## DBsubject(Linear algebra) ## DBchapter(Abstract vector spaces) ## DBsection(Basis and dimension) ## Date(10/11/2013) ## Institution('NAU') ## Author('Nandor Sieben') ## RevisedBy('Sean Fitzpatrick') ## Level(2) ## MO(1) ## KEYWORDS('linear algebra','basis','subspace') DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "MatrixReduce.pl", "parserMultiAnswer.pl", "PGcourse.pl", "PGML.pl", "PCCmacros.pl" ); $showPartialCorrectAnswers = 1; sub rank { Context('Fraction'); 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; } # Context("Fraction"); Context("Matrix"); $I = Matrix([[1,0],[0,1]]); $A = Matrix([[1,0],[0,-1]]); $B = Matrix([[0,1],[0,0]]); $C = Matrix([[0,0],[1,0]]); $basis = List($A, $B, $C); $basis_checker = sub { my ( $correct, $student, $self ) = @_; my @errors; my $s = @{$student}; my @c = @{$correct}; my $s0 = Matrix($s[0]); my $s1 = Matrix($s[1]); my $s2 = Matrix($s[2]); if (0 != $s0->trace) { push(@errors, "Your first matrix does not have trace zero."); } if (0 != $s1->trace) { push(@errors, "Your second matrix does not have trace zero."); } if (0 != $s2->trace) { push(@errors, "Your third matrix does not have trace zero."); } return (0, @errors), if @errors; if (rank(Matrix([ [$s0->element(1,1),$s0->element(1,2),$s0->element(2,1)], [$s1->element(1,1),$s1->element(1,2),$s1->element(2,1)], [$s2->element(1,1),$s2->element(1,2),$s2->element(2,1)]]))==3) { # Three matrices in basis, so score is out of 3. return (3, "Great work!"); } return (2, "The matrices in your basis must be linearly independent"); }; BEGIN_PGML Find a basis for the vector space [` \lbrace A\in M_{22}(\mathbb R) \mid \text{tr}(A)=0\rbrace`] of [`2\times 2`] matrices with trace 0. [____________________]{$basis->cmp(list_checker => $basis_checker)} [@KeyboardInstructions('Enter your answer as a comma-separated list of matrices. Use the syntax [|[[a,b],[c,d]]|] to enter your matrices.')@]** END_PGML ENDDOCUMENT();