########################################################## # # Example showing how to switch different contexts # DOCUMENT(); # This should be the first executable line in the problem. loadMacros( "PGbasicmacros.pl", "PGanswermacros.pl", "Parser.pl", "parserTables.pl", ); TEXT(beginproblem()); BEGIN_TEXT $BEGIN_ONE_COLUMN In this problem, we compare formulas in complex and vector contexts. Note the difference between how ${BTT}i${ETT} is treated in the two contexts. Note that 'Number' comprises both real and complex numbers. $PAR Assuming that ${BTT}${DOLLAR}x = Formula('x')${ETT}, it can be used as follows: $PAR END_TEXT $x = Formula('x'); ########################################################## # # Use Complex context # Context('Complex'); BEGIN_TEXT \{Title("The Complex context:")\} $PAR \{ParserTable( 'i', 'Formula("1+3i")', 'Formula("x+3i")', '1 + 3*i', '$x + 3*i', '$z = tan(2*i)', 'Formula("sinh(zi)")', 'Formula("3i+4j-k")', 'Formula("3i+4j-k")->eval', '3*i + 4*j - k', )\} $PAR$BR END_TEXT ########################################################## # # Use Vector context # Context('Vector'); BEGIN_TEXT \{Title("The Vector context:")\} $PAR \{ParserTable( 'i', 'Formula("1+3i")', 'Formula("x+3i")', '1 + 3*i', '$x + 3*i', '$z = tan(2*i)', 'Formula("sinh(zi)")', 'Formula("3i+4j-k")', 'Formula("3i+4j-k")->eval', '3*i + 4*j - k', )\} $END_ONE_COLUMN END_TEXT ########################################################### ENDDOCUMENT(); # This should be the last executable line in the problem.