DOCUMENT();
loadMacros(
"PGstandard.pl", # Standard macros for PG language
"MathObjects.pl",
"parserMultiAnswer.pl",
);
TEXT(beginproblem());
Context("Matrix");
do{
$e1 = non_zero_random(-5,5);
$e2 = non_zero_random(-5,5);
} while ($e1 == $e2);
$D = Matrix([[$e1,0],[0,$e2]]);
$Psol = Matrix( [ [ 1,0], [0,1 ] ] );
$Dsol = Matrix( [ [ $e1,0], [0,$e2 ] ] );
$multians = MultiAnswer($Dsol, $Psol)->with(singleResult=>1,
checker => sub{
my($correct, $student, $self) = @_;
my ($Dstu, $Pstu) = @{$student};
my @c = @{$correct};
return $A*$Pstu == $Pstu*$Dstu;
}
);
Context() ->texStrings;
BEGIN_TEXT
Let \(A=$D \). Find an invertible matrix \( P \) and a diagonal \( D \) such that \( PDP^{-1} = A \). The matrix \( D \) should have the eigenvalues of \( A \) on its diagonal.
$BR
\(D\) =\{$multians ->ans_array(3)\},\(P\) =\{$multians ->ans_array(3)\}
END_TEXT
Context()->normalStrings;
ANS( $multians->cmp( ) );
ENDDOCUMENT();
When I enter the correct answer the message given is:
Can't convert '' to a Matrix |
Dave