It's been a while since I've done any work with problem authoring, so I was a bit stumped when I was asked about this error message:
ERROR caught by Translator while processing problem file:tmpEdit/setwml_testing/blankProblem.pg.admin.tmp
****************
Variable 'y' is not defined in this context; see position 74 of formula at line 99 of [PG]/macros/Parser.pl
Died within main::Formula called at line 99 of [PG]/macros/Parser.pl
from within main::Compute called at line 48 of [TMPL]/tmpEdit/setwml_testing/blankProblem.pg.admin.tmp
****************
------Input Read
1 ## DESCRIPTION
2 ##
3 ## ENDDESCRIPTION
4
5 ## DBsubject('Algebra')
6 ## DBchapter('Basic Algebra')
7 ## DBsection('Algebraic Expressions')
8 ## Date('')
9 ## Author('')
10 ## Institution('')
11 ## TitleText1('')
12 ## EditionText1('')
13 ## AuthorText1('')
14 ## Section1('')
15 ## Problem1('')
16
17 DOCUMENT();
18
19 loadMacros(
20 "PGstandard.pl",
21 "MathObjects.pl",
22 );
23
24 Context("Numeric");
25
26 $a = list_random(3, 4, 5);
27 $b = list_random(1, 2, 3, 4, 5);
28 $c = list_random(2, 3);
29 $d = list_random(2, 3, 4);
30 $e = list_random(3, 6);
31 $f = list_random(1, 2, 3);
32 $g = list_random(2, 4);
33 $h = list_random(3, 4, 5);
34
35
36 TEXT(beginproblem());
37 Context()->texStrings;
38 BEGIN_TEXT
39 Simplify: $BR
40
41 \( ($g x^$a $f y^$b)^2 \)
42 \( ($h x^$e $d y^$c)^3 \)
43
44 \{ans_rule(6)\}
45
46 END_TEXT
47 Context()->normalStrings;
48
49 ANS(Compute(
50 "($g ^ 2) * ($h ^ 3) * x ^ (2 * $a + 3 * $e)
51 ($f ^ 2) * ($d ^ 3) * y ^ (2 * $b + 3 * $c)"
52 )->cmp());
53 Context()->texStrings;
54 SOLUTION(EV3(<<'END_SOLUTION'));
55
56 END_SOLUTION
57 Context()->normalStrings;
58
59 ENDDOCUMENT();
When just using x, everything is fine, which seems strange to me, but perhaps x is associated with some magic?
The problem is that 'y' isn't defined in this context. :-)
The Numeric context has only one variable predefined: x. If you want additional variables, you need to add them into the context. For example
Context("Numeric")->variables->add(y=>'Real');when you declare the context would make y defined as well.
Davide