… | |
… | |
7 | Implements a context in which complex numbers can be entered, |
7 | Implements a context in which complex numbers can be entered, |
8 | but no complex operations are permitted. So students will |
8 | but no complex operations are permitted. So students will |
9 | be able to perform operations within the real and imaginary |
9 | be able to perform operations within the real and imaginary |
10 | parts of the complex numbers, but not between complex numbers. |
10 | parts of the complex numbers, but not between complex numbers. |
11 | |
11 | |
12 | Context("LimitedComplex") |
12 | Context("LimitedComplex") |
13 | |
13 | |
14 | Complex Numbers can still be entered in a+bi or a*e^(bt) form. |
14 | Complex Numbers can still be entered in a+bi or a*e^(bt) form. |
15 | The e and i are allowed to be entered only once, so we have |
15 | The e and i are allowed to be entered only once, so we have |
16 | to keep track of that, and allow SOME complex operations, |
16 | to keep track of that, and allow SOME complex operations, |
17 | but only when one term is one of these constants (or an expression |
17 | but only when one term is one of these constants (or an expression |
18 | involving it that we've already OKed). |
18 | involving it that we've already OKed). |
19 | |
19 | |
20 | You control which format to use by setting the complex_format |
20 | You control which format to use by setting the complex_format |
21 | context flag to 'cartesian', 'polar' or 'either'. E.g., |
21 | context flag to 'cartesian', 'polar' or 'either'. E.g., |
22 | |
22 | |
23 | Context()->flags->set(complex_format => 'polar'); |
23 | Context()->flags->set(complex_format => 'polar'); |
24 | |
24 | |
25 | The default is 'either'. There are predefined contexts that |
25 | The default is 'either'. There are predefined contexts that |
26 | already have these values set: |
26 | already have these values set: |
27 | |
27 | |
28 | Context("LimitedComplex-cartesian"); |
28 | Context("LimitedComplex-cartesian"); |
29 | Context("LimitedComplex-polar"); |
29 | Context("LimitedComplex-polar"); |
30 | |
30 | |
31 | You can require that the a and b used in these forms be strictly |
31 | You can require that the a and b used in these forms be strictly |
32 | numbers (not expressions) by setting the strict_numeric flag and |
32 | numbers (not expressions) by setting the strict_numeric flag and |
33 | disabling all the functions: |
33 | disabling all the functions: |
34 | |
34 | |
35 | Context()->flags->set(strict_numeric=>1); |
35 | Context()->flags->set(strict_numeric=>1); |
36 | Context()->functions->disable('All'); |
36 | Context()->functions->disable('All'); |
37 | |
37 | |
38 | There are predefined contexts that already have these values |
38 | There are predefined contexts that already have these values |
39 | set: |
39 | set: |
40 | |
40 | |
41 | Context("LimitedComplex-cartesian-strict"); |
41 | Context("LimitedComplex-cartesian-strict"); |
42 | Context("LimitedComplex-polar-strict"); |
42 | Context("LimitedComplex-polar-strict"); |
43 | Context("LimitedComplex-strict"); |
43 | Context("LimitedComplex-strict"); |
44 | |
44 | |
45 | =cut |
45 | =cut |
46 | |
46 | |
47 | loadMacros("MathObjects.pl"); |
47 | loadMacros("MathObjects.pl"); |
48 | |
48 | |