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
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 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
2 ## Algebra problem: simplifying fraction using conjugation
3 ## Rationalize the numerator
6 ##KEYWORDS('algebra', 'powers')
8 DOCUMENT(); # This should be the first executable line in the problem.
19 $context = Context("Numeric");
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)