Trigonometric identities
Download file: TrigIdentities.pg
DOCUMENT(); loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl');
Preamble
These standard macros need to be loaded.$ans = Compute('sin(x)')->cmp( checker => sub { my ($correct, $student, $ansHash) = @_; my $stu_ans = $student->reduce; Value->Error('There is a simpler answer') if $stu_ans->string eq 'cos(x)*tan(x)'; return $student == $correct; } );
Setup
To prevent the student from just entering the given expression, we create a custom answer checker, which 1) performs a ->reduce
which will do some small simplification, 2) returns an error if the original expression was put in and 3) then checks if the answer is correct.
An alternative method to doing this is in Proving Identities.
BEGIN_PGML Simplify the expression as much as possible. [`\tan(x) \cos(x) =`] [_]{$ans}{15} END_PGML
Statement
This is the problem statement in PGML.BEGIN_PGML_SOLUTION Solution explanation goes here. END_PGML_SOLUTION COMMENT( 'Prevents students from entering trivial identities (entering what they ' . 'were given)'); ENDDOCUMENT();
Solution
A solution should be provided here.