I am new to authoring problems, so forgive me if this has already been covered (though I did search) or if I am making a silly mistake.
My understanding of the Compute( ) function is that it will automatically determine the appropriate MathObject, be it Real, Complex, Formula, etc.
It works fine for me for numbers. However, when I attempt to use it for a Formula, I get the error below. It seems to require that I provide a value for the variable as a second parameter. (Notice that no error is detected on line 21 (Formula) or line 22 (addtional argument to Compute).
As a result, I am forced to use Formula( ), but this is a poor work-around for displaying a formulaic answer to students when the formula expression contains non-terminating decimals.
Am I doing something incorrectly? Any help would be greatly appreciated
Thanks,
Christopher
--------------------------------
Error messages
No value given for variable 'x'; see position 1 of formula at line 34 of [PG]/macros/Parser.pl Died within main::Compute called at line 23 of [TMPL]/tmpEdit/LCX/Algebra/rationalizingCubes.pg.professor.tmp
Error details
Problem13
ERROR caught by Translator while processing problem file:tmpEdit/LCX/Algebra/rationalizingCubes.pg.professor.tmp
****************
No value given for variable 'x'; see position 1 of formula at line 34 of [PG]/macros/Parser.pl
Died within main::Compute called at line 23 of [TMPL]/tmpEdit/LCX/Algebra/rationalizingCubes.pg.professor.tmp
****************
------Input Read
1 #DESCRIPTION
2 ## Algebra problem: simplifying fraction using conjugation
3 ## Rationalize the numerator
4 ##ENDDESCRIPTION
5
6 ##KEYWORDS('algebra', 'powers')
7
8 DOCUMENT(); # This should be the first executable line in the problem.
9
10 loadMacros(
11 "PG.pl",
12 "PGbasicmacros.pl",
13 "PGchoicemacros.pl",
14 "PGanswermacros.pl",
15 "PGauxiliaryFunctions.pl",
16 "MathObjects.pl",
17 "Parser.pl"
18 );
19 $context = Context("Numeric");
20
21 $f = Formula("x+1");
22 $g = Compute("x+1", x=>1);
23 $h = Compute("x+1");
The Compute() command was originally intended to turn formulas into their computed MathObject values, and so early versions did not return Formula objects. That was fixed some time ago (Back in the summer of 2007), so I suspect you have an older version of WeBWorK's pg library. You may want to update to a more recent version. (This change was in version 1.7 of pg/macros/Parser.pl)
Davide
Davide