Hello:
I defined the function cis( ), so students can enter 2*cis(pi) to represent 2*(cos(pi)+sin(pi)). However when the answer is r*cis(0), I get the error:
Can't generate enough valid points for comparison
Please help. Thank you!
Carl Yao
Portland Community College
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"PGcourse.pl",,
);
##############################################
package my::Complex;
our @ISA = ('Value::Complex');
sub cis {
my $z = shift;
return cos($z) + main::i * sin($z);
}
package main;
Context("Complex");
Context()->{value}{Complex} = 'my::Complex';
Context()->constants->set(i => {value => my::Complex->new(0,1)});
Context()->functions->add(cis => {
class => 'Parser::Function::complex', TeX => '\operatorname{cis}',
complex => 1, isCommand => 1
});
sub cis {Parser::Function->call("cis", my::Complex->new(@_))}
Context()->flags->set(reduceConstantFunctions => 0);
$ans = Formula("2*cis(0)");
##############################################
TEXT(beginproblem());
BEGIN_PGML
Correct answer is [` 2*cis(0)= `]
[________________________]{$ans}
END_PGML
##############################################
ENDDOCUMENT();