## DESCRIPTION ## Trigonometry: periodic answers ## ENDDESCRIPTION ## KEYWORDS('trigonometry', 'periodic answer') ## DBsubject('WeBWorK') ## DBchapter('WeBWorK Tutorial') ## DBsection('Fort Lewis Tutorial 2011') ## Date('01/30/2011') ## Author('Paul Pearson') ## Institution('Fort Lewis College') ## TitleText1('') ## EditionText1('') ## AuthorText1('') ## Section1('') ## Problem1('') #################################### # Initialization DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "AnswerFormatHelp.pl", "answerHints.pl", ); TEXT(beginproblem()); #################################### # Setup Context("Numeric"); # # We redefine the function whose # name is tan(x) to take values # exp(pi * x). # Context()->functions->remove("tan"); package NewFunc; # this next 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 functions to the Context Context()->functions->add( tan => {class =>'NewFunc', TeX =>'\tan'}, ); #################################### # Main Text Context()->texStrings; BEGIN_TEXT Simplify the expression as much as possible. $BR $BR \( \tan(x) \cos(x) \) = \{ ans_rule(20) \} \{ AnswerFormatHelp("formulas") \} END_TEXT Context()->normalStrings; ################################### # Answer evaluation $showPartialCorrectAnswers = 1; ANS(Formula("sin(x)")->cmp() ->withPostFilter(AnswerHints( Compute("tan(x)*cos(x)") => "No credit for entering what you were given.", )) ); ################################### # Solution Context()->texStrings; BEGIN_SOLUTION ${PAR}SOLUTION:${PAR} Solution explanation goes here. END_SOLUTION Context()->normalStrings; COMMENT("MathObject version. Prevents students from entering trivial identities (entering what they were given). Redefines 'tan(x)' internally as 'exp(pi*x)'."); ENDDOCUMENT();