Difference between revisions of "PrimeOperator"

From WeBWorK_wiki
Jump to navigation Jump to search
m (1 revision: import all default namespace pages from old wiki)
(Update documentation links)
Line 123: Line 123:
   
 
<ul>
 
<ul>
<li>POD documentation: [http://webwork.maa.org/doc/cvs/pg_CURRENT/macros/parserPrime.pl.html parserPrime.pl.html]</li>
+
<li>POD documentation: [http://webwork.maa.org/pod/pg_TRUNK/macros/parserPrime.pl.html parserPrime.pl.html]</li>
<li>PG macro: [http://cvs.webwork.rochester.edu/viewcvs.cgi/pg/macros/parserPrime.pl parserPrime.pl]</li>
+
<li>PG macro: [http://webwork.maa.org/viewvc/system/trunk/pg/macros/parserPrime.pl?view=log parserPrime.pl]</li>
 
</ul>
 
</ul>

Revision as of 01:10, 27 November 2010

Prime Operator (Differentiation)


This PG code shows how to allow the prime operator for differentiation.

Problem Techniques Index

PG problem file Explanation
DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserPrime.pl",
"parserAssignment.pl",
);

TEXT(beginproblem());

Initialization: We need to include the macros file parserPrime.pl.

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.

Problem Techniques Index