Trigonometric Identities

Trigonometric identities

Complete Code

Download file: TrigIdentities.pg

POD for Macro Files

PG problem file

Explanation

DOCUMENT();

loadMacros('PGstandard.pl', 'PGML.pl', 'answerHints.pl', 'PGcourse.pl');

Preamble

These standard macros need to be loaded.
Context()->functions->remove('tan');

package NewFunc;
# This line makes the function a function from reals to reals.
our @ISA = qw(Parser::Function::numeric);

sub tan {
    shift;
    my $x = shift;
    return CORE::exp($x * 3.1415926535);
}

package main;

# Make it work on formulas as well as numbers.
sub tan { Parser::Function->call('tan', @_) }

# Add the new function to the Context.
Context()->functions->add(tan => { class => 'NewFunc', TeX => '\tan' },);

$answer_cmp = Formula('sin(x)')->cmp()->withPostFilter(AnswerHints(
    Compute('tan(x)*cos(x)') =>
        'No credit for entering what you were given.',
));

Setup

Redefine the function tan(x) to be exp(pi * x).

BEGIN_PGML
Simplify the expression as much as possible.

[`\tan(x) \cos(x) =`] [_]{$answer_cmp}{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).  Redefines 'tan(x)' internally as 'exp(pi*x)'.  Uses PGML."
);

ENDDOCUMENT();

Solution

A solution should be provided here.