###########################################################################
# initialization
###########################################################################
DOCUMENT();
loadMacros(
"MathObjects.pl",
"PGstandard.pl",
"parserMultiAnswer.pl",
);
TEXT(beginproblem());
$showPartialCorrectAnswers = 1;
###########################################################################
# setup contexts and variables
###########################################################################
Context("Complex");
$a = Complex("i");
Context("Matrix")->strings->add("true"=>{}, "false"=>{});
$A = Matrix([0,1],[-1,0]);Context()->{cmpDefaults}{Matrix}{showDimensionHints} = 0;
$answer = MultiAnswer($A,$a)->with(
singleResult => 0,
checker => sub {
my ($c,$s,$self) = @_;
my ($s1,$s2) = @{$s};
return [0,0] if !($s1->isSquare);
@d = $s1->dimensions;
$test1 = 0;
my $T = $s1 - $s2*Value::Matrix->I($d[0]);
$test1 = 1 if $T->det == 0;
$test2 = 0;
$test2 = 1 if $a->Im != 0;
return [1,1] if $test1 == 1 && $test2 == 1;
return [0,0];
}
);
###########################################################################
# check the answer
###########################################################################
ANS($answer->cmp());
###########################################################################
# state the problem
###########################################################################
Context()->texStrings;
BEGIN_TEXT
Determine if the following statement is true or false:
$PAR
$SPACE $SPACE A square matrix \(A\) having real entries also has real eigenvalues.
$PAR
If the answer is true, then type ${BBOLD}true${EBOLD} in one of the blanks. If the answer is false, then provide a square matrix \(A\) with real entries and one of its complex eigenvalues. $PAR
\(A = \) \{$answer->ans_rule(35)\} $BR
Exactly one complex eigenvalue of \(A\): \{$answer->ans_rule(20)\}
$PAR
${BBOLD}Help:${EBOLD} To enter a matrix use $BBOLD [[ ],[ ]] $EBOLD. For example, to enter the \(2\times 3\) matrix
$PAR\[
\left[\begin{array}{ccc}
1 & 2 & 3 \\ 6 & 5 & 4
\end{array}\right]
\]$PAR you would type [[1,2,3],[6,5,4]], so each inside set of [ ] represents a row.
END_TEXT
Context()->normalStrings;
The issue I am having is that it gives the following errors:
Operator or semicolon missing before *Value::Matrix at line 51 of (eval 2279)
Ambiguous use of * resolved as operator * at line 51 of (eval 2279)
However, it seems to actually work and take answers:
I think the error basically means that there is no operator * defined for a complex object times a matrix? Any ideas how how I can fix this? Thank you so much in advance!