PrimeOperator

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Prime Operator (Differentiation)

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

PG problem file Explanation
DOCUMENT();

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

TEXT(beginproblem());

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

parser::Assignment->Allow;

# only use partial derivatives with respect to x
parser::Prime->Enable("x");

\$answer1 = Formula("y = k x'");

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.