NAME

parserFunctionPrime.pl - Allow f' notation for parserFunction objects.

DESCRIPTION

This file implements prime notation for derivatives for functions added to the Context via a parserFunction() call. For example, if you have done

parserFunction("f(x)" => "3x^2+x-2");

then you can use

$f = Formula("f'(x)");

to get the equivalent of Formula("6x+1"), and

$f = Formula("f''(x)");

for the equivalent of Formula("6"). Students can also type primes in their answers, so if you define parserFunction's for f and g, you can ask "What is the derivative of f(g(x))" and expect them to answer "f'(g(x))g'(x)" (and you can also type the same thing as the correct answer for the problem).

To enable prime notation, first load the parserFunctionPrime.pl file, and then call parser::FunctionPrime->Enable() command after having selected the Context that you want to use. For example:

loadMacros(
    "PGstandard.pl",
    "parserFunctionPrime.pl",
    "PGcourse.pl",
);

Context("Numeric");
parser::FunctionPrime->Enable();

Note that parserFunctionPrime.pl loads parserFunction.pl automatically, so you don't have to load both.

parser::FunctionPrime->Enable($context)

This enables prime notation for parserFunction objects in the given context (or if no context is given, in the current context).

parser::FunctionPrime->Disable($context)

This disables prime notation for parserFunction objects in the given context (or if no context is given, in the current context).