DifferentiatingFormulas: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 52: | Line 52: | ||
$fxa = $fx->eval(x=>"$a"); | $fxa = $fx->eval(x=>"$a"); | ||
$fy = $f->D('y'); | $fy = $f->D('y'); | ||
$ | $fyx = $fy->D('x'); | ||
</pre> | </pre> | ||
</td> | </td> | ||
Line 82: | Line 82: | ||
\( f_y(x,y) \) = \{ans_rule(20)\} | \( f_y(x,y) \) = \{ans_rule(20)\} | ||
$PAR | $PAR | ||
\( f_{ | \( f_{yx} (x,y) \) = \{ans_rule(20)\} | ||
END_TEXT | END_TEXT | ||
Context()->normalStrings; | Context()->normalStrings; | ||
Line 102: | Line 102: | ||
ANS( $fxa->cmp() ); | ANS( $fxa->cmp() ); | ||
ANS( $fy ->cmp() ); | ANS( $fy ->cmp() ); | ||
ANS( $ | ANS( $fyx->cmp() ); | ||
ENDDOCUMENT; | ENDDOCUMENT; |
Revision as of 01:32, 4 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'); $fyx = $fy->D('x'); |
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_{yx} (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( $fyx->cmp() ); ENDDOCUMENT; |
Answer Evaluation: As is the answer. |