Difference between revisions of "PrimeOperator"
Jump to navigation
Jump to search
(New page: <h2>Prime Operator (Differentiation)</h2> <!-- Header for these sections -- no modification needed --> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> <em>Thi...) |
m (1 revision: import all default namespace pages from old wiki) |
(No difference)
|
Revision as of 15:19, 14 May 2010
Prime Operator (Differentiation)
This PG code shows how to allow the prime operator for differentiation.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserPrime.pl", "parserAssignment.pl", ); TEXT(beginproblem()); |
Initialization:
We need to include the macros file |
Context("Numeric")->variables->add(y=>"Real"); Context()->constants->add(k=>0.01); Context()->flags->set(formatStudentAnswer=>'parsed'); parser::Assignment->Allow; # only use partial derivatives with respect to x parser::Prime->Enable("x"); $answer1 = Formula("y = k x'"); $answer2 = Formula("(x^2)' + (y^2)'"); parser::Prime->Disable; |
Setup: We need to enable the prime operator, and ought to also specify the variable for partial differentiation. |
BEGIN_TEXT Enter the equation \( y = k x' \) or \( y = k \): \{ ans_rule(20) \} $PAR Since we defined the prime operator as the partial derivative with respect to \( x \), enter the expression \( (x^2+y^2)' \) or \( 2x \): \{ ans_rule(20) \} END_TEXT |
Main Text: The problem text section of the file is as we'd expect. |
$showPartialCorrectAnswers = 1; ANS( $answer1->cmp() ); ANS( $answer2->cmp() ); ENDDOCUMENT(); |
Answer Evaluation: As is the answer. |
- POD documentation: parserPrime.pl.html
- PG macro: parserPrime.pl