[system] / trunk / pg / macros / contextInequalities.pl Repository: Repository Listing bbplugincoursesdistsnplrochestersystemwww

# Diff of /trunk/pg/macros/contextInequalities.pl

Revision 5550 Revision 5551
2
3Context("Inequalities"), Context("Inequalities-Only") - Provides contexts that
4allow intervals to be specified as inequalities.
5
7
8Implements contexts that provides for inequalities that produce
9the cooresponding Interval, Set or Union MathObjects. There are
10two such contexts: Context("Inequalities"), in which both
11intervals and inequalities are defined, and Context("Inequalities-Only"),
12which allows only inequalities as a means of producing intervals.
13
15
17
18 Context("Inequalities");
19 \$S1 = Compute("1 < x <= 4");
20 \$S2 = Inequality("(1,4]"); # force interval to be inequality
21
22 Context("Inequalities-Only");
23 \$S1 = Compute("1 < x <= 4");
24 \$S2 = Inequality("(1,4]"); # generates an error
25
26 \$S3 = Compute("x < -2 or x > 2"); # forms a Union
27 \$S4 = Compute("x = 1"); # forms a Set
28
29You can set the "noneWord" flag to specify the string to
30use when the inequalities specify the empty set. By default,
31it is "NONE", but you can change it to other strings. Be sure
32that you use a string that is defined in the Context, however,
33if you expect the student to be able to enter it. For example
34
35 Context("Inequalities");
37 Context()->flags->set(noneWord=>"EmptySet");
38
39creates an empty set as a named constant and uses that name.
40
41Inequalities and interval notation both can coexist side by
42side, but you may wish to convert from one to the other.
43Use Inequality() to convert from an Interval, Set or Union
44to an Inequality, and use Interval(), Set(), or Union() to
45convert from an Inequality object to one in interval notation.
46For example:
47
48 \$I0 = Compute("(1,2]"); # the interval (1,2]
49 \$I1 = Inequality(\$I); # the inequality 1 < x <= 2
50
51 \$I0 = Compute("1 < x <= 2"); # the inequality 1 < x <= 2
52 \$I1 = Interval(\$I0); # the interval (1,2]
53
54Note that ineqaulities and inervals can be compared and combined
55regardless of the format, so \$I0 == \$I1 is true in either example
56above.
57
58=cut
59
2 61
3sub _contextInequalities_init {Inequalities::Init()} 62sub _contextInequalities_init {Inequalities::Init()}
4
6
7 #########################################################################
8 #
9 # Implements contexts that provides for inequalities that produce
10 # the cooresponding Interval, Set or Union MathObjects. There are
11 # two such contexts: Context("Inequalities"), in which both
12 # intervals and inequalities are defined, and Context("Inequalities-Only"),
13 # which allows only inequalities as a means of producing intervals.
14 #
16 #
17 # Context("Inequalities");
18 # \$S1 = Compute("1 < x <= 4");
19 # \$S2 = Inequality("(1,4]"); # force interval to be inequality
20 #
21 # Context("Inequalities-Only");
22 # \$S1 = Compute("1 < x <= 4");
23 # \$S2 = Inequality("(1,4]"); # generates an error
24 #
25 # \$S3 = Compute("x < -2 or x > 2"); # forms a Union
26 # \$S4 = Compute("x = 1"); # forms a Set
27 #
28 # You can set the "noneWord" flag to specify the string to
29 # use when the inequalities specify the empty set. By default,
30 # it is "NONE", but you can change it to other strings. Be sure
31 # that you use a string that is defined in the Context, however,
32 # if you expect the student to be able to enter it. For example
33 #
34 # Context("Inequalities");
36 # Context()->flags->set(noneWord=>"EmptySet");
37 #
38 # creates an empty set as a named constant and uses that name.
39 #
40 # Inequalities and interval notation both can coexist side by
41 # side, but you may wish to convert from one to the other.
42 # Use Inequality() to convert from an Interval, Set or Union
43 # to an Inequality, and use Interval(), Set(), or Union() to
44 # convert from an Inequality object to one in interval notation.
45 # For example:
46 #
47 # \$I0 = Compute("(1,2]"); # the interval (1,2]
48 # \$I1 = Inequality(\$I); # the inequality 1 < x <= 2
49 #
50 # \$I0 = Compute("1 < x <= 2"); # the inequality 1 < x <= 2
51 # \$I1 = Interval(\$I0); # the interval (1,2]
52 #
53 # Note that ineqaulities and inervals can be compared and combined
54 # regardless of the format, so \$I0 == \$I1 is true in either example
55 # above.
56 #
57 ######################################################################
58
59=cut
60 63
61package Inequalities; 64package Inequalities;
62 65
63# 66#
64# Sets up the two inequality contexts 67# Sets up the two inequality contexts

Legend:
 Removed from v.5550 changed lines Added in v.5551