Parent Directory
|
Revision Log
Backporting MathObject documentation to rel-2-4-5
1 ########################################################## 2 # 3 # Example showing how to switch different contexts 4 # 5 6 DOCUMENT(); # This should be the first executable line in the problem. 7 8 loadMacros( 9 "PGbasicmacros.pl", 10 "PGanswermacros.pl", 11 "Parser.pl", 12 "parserTables.pl", 13 ); 14 15 TEXT(beginproblem()); 16 17 BEGIN_TEXT 18 $BEGIN_ONE_COLUMN 19 20 In this problem, we compare formulas in complex and vector contexts. 21 Note the difference between how ${BTT}i${ETT} is treated in the two 22 contexts. Note that 'Number' comprises both real and complex numbers. 23 $PAR 24 25 Assuming that ${BTT}${DOLLAR}x = Formula('x')${ETT}, it can be used as follows: 26 $PAR 27 28 END_TEXT 29 30 $x = Formula('x'); 31 32 ########################################################## 33 # 34 # Use Complex context 35 # 36 37 Context('Complex'); 38 39 BEGIN_TEXT 40 \{Title("The Complex context:")\} 41 $PAR 42 \{ParserTable( 43 'i', 44 'Formula("1+3i")', 45 'Formula("x+3i")', 46 '1 + 3*i', 47 '$x + 3*i', 48 '$z = tan(2*i)', 49 'Formula("sinh(zi)")', 50 'Formula("3i+4j-k")', 51 'Formula("3i+4j-k")->eval', 52 '3*i + 4*j - k', 53 )\} 54 $PAR$BR 55 END_TEXT 56 57 58 ########################################################## 59 # 60 # Use Vector context 61 # 62 63 Context('Vector'); 64 65 BEGIN_TEXT 66 \{Title("The Vector context:")\} 67 $PAR 68 \{ParserTable( 69 'i', 70 'Formula("1+3i")', 71 'Formula("x+3i")', 72 '1 + 3*i', 73 '$x + 3*i', 74 '$z = tan(2*i)', 75 'Formula("sinh(zi)")', 76 'Formula("3i+4j-k")', 77 'Formula("3i+4j-k")->eval', 78 '3*i + 4*j - k', 79 )\} 80 81 $END_ONE_COLUMN 82 END_TEXT 83 84 ########################################################### 85 86 ENDDOCUMENT(); # This should be the last executable line in the problem.
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |