Difference between revisions of "DifferentiatingFormulas"
Jump to navigation
Jump to search
(New page: <h2>Differentiating Formulas: PG Code Snippet</h2> <!-- Header for these sections -- no modification needed --> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"...) |
|||
Line 34: | Line 34: | ||
<p> |
<p> |
||
<b>Initialization:</b> |
<b>Initialization:</b> |
||
− | In the initialization section, we need to include the macro file <code>MathObjects.pl</code>. |
+ | In the initialization section, we need to include the macro file <code>MathObjects.pl</code> or be using a parser that loads MathObjects.pl automatically. |
</p> |
</p> |
||
</td> |
</td> |
Revision as of 20:29, 3 March 2010
Differentiating Formulas: PG Code Snippet
This PG code shows how to differentiate a MathObjects Formula.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", ); TEXT(beginproblem()); |
Initialization:
In the initialization section, we need to include the macro file |
Context("Numeric")->variables->add(y=>"Real"); $a = random(2,4,1); $f = Formula("x*y^2"); $fx = $f->D('x'); $fxa = $fx->eval(x=>"$a"); $fy = $f->D('y'); $fxy = $fx->D('y'); |
Setup:
The |
Context()->texStrings; BEGIN_TEXT Suppose \( f(x) = $f \). Then $PAR \( \displaystyle \frac{\partial f}{\partial x} \) = \{ans_rule(20)\} $PAR \( f_x ($a,y) \) = \{ans_rule(20)\} $PAR \( f_y(x,y) \) = \{ans_rule(20)\} $PAR \( f_{xy} (x,y) \) = \{ans_rule(20)\} END_TEXT Context()->normalStrings; |
Main Text: The problem text section of the file is as we'd expect. |
ANS( $fx->cmp() ); ANS( $fxa->cmp() ); ANS( $fy->cmp() ); ANS( $fxy->cmp() ); ENDDOCUMENT; |
Answer Evaluation: As is the answer. |