Allowing primes in student answers.
Download file: PrimesInFormulas.pg
DOCUMENT();
loadMacros(
'PGstandard.pl', 'PGML.pl',
'parserImplicitEquation.pl', 'PGcourse.pl'
);
Preamble
For this problem a differential equation is the answer, the variables
in that equation will include y' and y'', and
the resulting equation will be implicit. So the macro parserImplicitEquation.pl
is used.
Context('ImplicitEquation');
Context()->variables->{namePattern} = qr/[ty]'*/i;
Context()->variables->are(
'y' => 'Real',
"y'" => 'Real',
"y''" => 'Real',
't' => 'Real',
);
$diffeq = ImplicitEquation("y'' + 2y' + y = cos(t)");
Setup
Switch to the ImplicitEquation context and then include
the variables y, y', y'', and
t.
Setting
Context()->variables->{namePattern} = qr/[ty]'*/i
allows primes to be included in the answer.
BEGIN_PGML
Suppose this is a word problem that asks students to set up a differential
equation and enter their differential equation as the answer.
Enter your differential equation below in terms of [`y`], [`y^{\prime}`],
[`y^{\prime\prime}`], [`t`].
(Suppose the answer is the differential equation [`[$diffeq]`].)
[_]{$diffeq}{20} [@ helpLink('equations') @]*
END_PGML
Statement
This is the problem statement in PGML.BEGIN_PGML_SOLUTION Solution explanation goes here. END_PGML_SOLUTION ENDDOCUMENT();
Solution
A solution should be provided here.