Allowing primes in student answers.
Download file: PrimesInFormulas.pg
DOCUMENT(); loadMacros( 'PGstandard.pl', 'PGML.pl', 'parserImplicitEquation.pl', 'PGcourse.pl' );
Preamble
For this problem, we want to enter in differential equations, and the variables will be y', 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
We switch the context to ImplicitEquation
and then includes the variable y, y', y''
and t
. The line Context()->variables->{namePattern} = qr/[ty]'*/i;
is used to make sure that primes can 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.