## DBsubject(Linear algebra) ## DBchapter(Abstract vector spaces) ## DBsection(Basis and dimension) ## Date(10/11/2013) ## Institution(NAU) ## Author(Nandor Sieben) ## Level(2) ## MO(1) ## KEYWORDS('linear algebra','span') DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "AnswerFormatHelp.pl", "MatrixReduce.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; } $l=non_zero_random(-9,9,1); $p1=Formula("2*$l-1+x^2")->reduce; $p2=Formula("x")->reduce; $basis = List($p1, $p2); $listChecker = sub { my ( $correct, $student, $self ) = @_; my @errors; my ($s1,$s2) = @{$student}; my @c = @{$correct}; my $s1D=$s1->D('x'); my $s2D=$s2->D('x'); my $s1DD=$s1D->D('x'); my $s2DD=$s2D->D('x'); if ($s1D->eval(x=>$l) != $s1->eval(x=>1)) { push(@errors, "Your first polynomial does not have the right derivative."); } if ($s2D->eval(x=>$l) != $s2->eval(x=>1)) { push(@errors, "Your second polynomial does not have the right derivative."); } my $s1DDD=$s1DD->D('x'); my $s2DDD=$s2DD->D('x'); if ($s1DDD != Formula("0")) { push(@errors, "Your first polynomial is not in `P_2(\mathbb{R})`."); } if ($s2DDD != Formula("0")) { push(@errors, "Your second polynomial is not in `P_2(\mathbb{R})`."); } return (0, @errors) if @errors; my $a1=$s1->eval(x=>0); my $b1=$s1D->eval(x=>0); my $c1=$s1DD->eval(x=>0)/2; my $a2=$s2->eval(x=>0); my $b2=$s2D->eval(x=>0); my $c2=$s2DD->eval(x=>0)/2; if (rank(Matrix([$a1,$b1,$c1],[$a2,$b2,$c2])) ==2) { # correct answers list consists of 2 items, so score is out of 2 total. return (2, "Good job!"); } return (1, "A basis must consist of linearly independent elements."); }; BEGIN_PGML Find a basis [` \lbrace p(x), q(x) \rbrace `] for the vector space [`\lbrace f(x)\in P_2(\mathbb{R}) \mid f'([$l])=f(1) \rbrace`] where [`P_2(\mathbb{R})`] is the vector space of polynomials in [`x`] with degree less than or equal to 2. [__________]{$basis->cmp(list_checker => $listChecker)} [@KeyboardInstructions('Enter your answer as a comma-separated list of polynomials.')@]** END_PGML ENDDOCUMENT();