########################################################### # # Example showing how to use the Parser's function # answer checker. # DOCUMENT(); # This should be the first executable line in the problem. loadMacros( "PGbasicmacros.pl", "PGanswermacros.pl", "Parser.pl", "Differentiation.pl", ); TEXT(beginproblem()); ########################################################### # # The setup # Context('Numeric'); $x = Formula('x'); # used to construct formulas below. # # Define a function and its derivative and make them pretty # $a = random(1,8,1); $b = random(-8,8,1); $c = random(-8,8,1); $f = ($a*$x**2 + $b*$x + $c) -> reduce; $df = $f->D('x'); $x = random(-8,8,1); ########################################################### # # The problem text # Context()->texStrings; BEGIN_TEXT Suppose \(f(x) = $f\). $PAR Then \(f'(x)=\) \{ans_rule(20)\},$BR and \(f'($x)=\) \{ans_rule(20)\}. END_TEXT Context()->normalStrings; ########################################################### # # The answers # ANS($df->cmp); ANS($df->eval(x=>$x)->cmp); $showPartialCorrectAnswers = 1; ########################################################### ENDDOCUMENT(); # This should be the last executable line in the problem.