… | |
… | |
2 | |
2 | |
3 | sub _parserSolutionFor_init {}; # don't reload this file |
3 | sub _parserSolutionFor_init {}; # don't reload this file |
4 | |
4 | |
5 | =head1 DESCRIPTION |
5 | =head1 DESCRIPTION |
6 | |
6 | |
7 | ###################################################################### |
7 | ###################################################################### |
8 | # |
8 | # |
9 | # This is a Parser class that implements an answer checker that |
9 | # This is a Parser class that implements an answer checker that |
10 | # checks if a student's answer satisfies an implicit equation. |
10 | # checks if a student's answer satisfies an implicit equation. |
11 | # We define a SolutionFor object class that lets you specify an |
11 | # We define a SolutionFor object class that lets you specify an |
12 | # equality that the student answer must satisfy, and a point that |
12 | # equality that the student answer must satisfy, and a point that |
13 | # DOES satify the equation. The overloaded == operator will |
13 | # DOES satify the equation. The overloaded == operator will |
14 | # check if a given point satisfies the given equality. |
14 | # check if a given point satisfies the given equality. |
15 | # |
15 | # |
16 | # Use SolutionFor(equality,point[,options]) to create a SolutionFor object. |
16 | # Use SolutionFor(equality,point[,options]) to create a SolutionFor object. |
17 | # The equality is a Formula object containing an equality, or a string |
17 | # The equality is a Formula object containing an equality, or a string |
18 | # representing such a formula, and the point is a Point object or string |
18 | # representing such a formula, and the point is a Point object or string |
19 | # containing a point that satisfies the equation (to be used as the |
19 | # containing a point that satisfies the equation (to be used as the |
20 | # correct answer when the student asks to see the answers). |
20 | # correct answer when the student asks to see the answers). |
21 | # |
21 | # |
22 | # The variables to use are declared in the Context in the usual way, |
22 | # The variables to use are declared in the Context in the usual way, |
23 | # and the coordinates of the student point will be considered to be in |
23 | # and the coordinates of the student point will be considered to be in |
24 | # alphabetical order. You can override this by supplying the vars=>[...] |
24 | # alphabetical order. You can override this by supplying the vars=>[...] |
25 | # option, where you specify the variable names in the order you want the |
25 | # option, where you specify the variable names in the order you want the |
26 | # student to give them. E.g., vars=>['y','x'] will make the student answer |
26 | # student to give them. E.g., vars=>['y','x'] will make the student answer |
27 | # represent the point (y,x) rather than the default (x,y). |
27 | # represent the point (y,x) rather than the default (x,y). |
28 | # |
28 | # |
29 | # Usage examples: |
29 | # Usage examples: |
30 | # |
30 | # |
31 | # Context("Vector")->variables->are(x=>'Real',y=>'Real'); |
31 | # Context("Vector")->variables->are(x=>'Real',y=>'Real'); |
32 | # $f = SolutionFor("x^2 = cos(y)","(1,0)"); |
32 | # $f = SolutionFor("x^2 = cos(y)","(1,0)"); |
33 | # $f = SolutionFor("x^2 - y = 0",[2,4]); |
33 | # $f = SolutionFor("x^2 - y = 0",[2,4]); |
34 | # $f = SolutionFor("x^2 - y = 0",Point(4,2),vars=>['y','x']); |
34 | # $f = SolutionFor("x^2 - y = 0",Point(4,2),vars=>['y','x']); |
35 | # |
35 | # |
36 | # Then use |
36 | # Then use |
37 | # |
37 | # |
38 | # ANS($f->cmp); |
38 | # ANS($f->cmp); |
39 | # |
39 | # |
40 | # to get the answer checker for $f. |
40 | # to get the answer checker for $f. |
41 | # |
41 | # |
42 | # You can use $f->{f} to get the Formula object for the equality used |
42 | # You can use $f->{f} to get the Formula object for the equality used |
43 | # in the object, and $f->f(point) to determine if the given point is |
43 | # in the object, and $f->f(point) to determine if the given point is |
44 | # a solution to the equality or not. For example, if you want to include |
44 | # a solution to the equality or not. For example, if you want to include |
45 | # the TeX version of a formula within the text of a problem, you can use: |
45 | # the TeX version of a formula within the text of a problem, you can use: |
46 | # |
46 | # |
47 | # Context()->texStrings; |
47 | # Context()->texStrings; |
48 | # BEGIN_TEXT |
48 | # BEGIN_TEXT |
49 | # A solution to \($f->{f}\) is \((x,y)\) = \{ans_rule(30)\}. |
49 | # A solution to \($f->{f}\) is \((x,y)\) = \{ans_rule(30)\}. |
50 | # END_TEXT |
50 | # END_TEXT |
51 | # Context()->normalStrings; |
51 | # Context()->normalStrings; |
52 | # ANS($f->cmp); |
52 | # ANS($f->cmp); |
53 | # |
53 | # |
54 | ###################################################################### |
54 | ###################################################################### |
55 | |
55 | |
56 | =cut |
56 | =cut |
57 | |
57 | |
58 | # |
58 | # |
59 | # Create a SolutionFor object of the correct type |
59 | # Create a SolutionFor object of the correct type |