Add variables to the context.
Download file: OtherVariables.pg
DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl');
Preamble
These standard macros need to be loaded.Context()->variables->add(t=>"Real", y => 'Real', z => 'Real');
$f = Compute('-16 t^2 + 5 t + 4');
$g = Compute('x^2+y^2+z^2');
Context()->variables->add(rho => ['Real', TeX => '\rho']);
$h = Compute("sqrt(1+rho^2)");
Setup
Typically you either add or set the variables for the entire problem at the top of the setup section. In this case, we add y, z and t, all real numbers.
This allows us to use a greek letter as a variable. Note that we have used add for this. If we set this with are, then the other variables will be deleted upon answer checked and the student will get a variable not defined in this context error.
BEGIN_PGML
Enter the following formulas:
* [`[$f]=`] [____]{$f}
* [`[$g]=`] [____]{$g}
* [`[$h]=`] [____]{$h}
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.