1Math::Symbolic::ConstanUts(e3r)Contributed Perl DocumentMaattiho:n:Symbolic::Constant(3)
2
3
4
6 Math::Symbolic::Constant - Constants in symbolic calculations
7
9 use Math::Symbolic::Constant;
10 my $const = Math::Symbolic::Constant->new(25);
11 my $zero = Math::Symbolic::Constant->zero();
12 my $one = Math::Symbolic::Constant->one();
13 my $euler = Math::Symbolic::Constant->euler();
14 # e = 2.718281828...
15
17 This module implements numeric constants for Math::Symbolic trees.
18
19 EXPORT
20 None by default.
21
23 Constructor new
24 Takes hash reference of key-value pairs as argument. Special case: a
25 value for the constant instead of the hash. Returns a
26 Math::Symbolic::Constant.
27
28 Constructor zero
29 Arguments are treated as key-value pairs of object attributes. Returns
30 a Math::Symbolic::Constant with value of 0.
31
32 Constructor one
33 Arguments are treated as key-value pairs of object attributes. Returns
34 a Math::Symbolic::Constant with value of 1.
35
36 Constructor euler
37 Arguments are treated as key-value pairs of object attributes. Returns
38 a Math::Symbolic::Constant with value of e, the Euler number. The
39 object has its 'special' attribute set to 'euler'.
40
41 Constructor pi
42 Arguments are treated as key-value pairs of object attributes. Returns
43 a Math::Symbolic::Constant with value of pi. The object has its
44 'special' attribute set to 'pi'.
45
46 Method value
47 value() evaluates the Math::Symbolic tree to its numeric
48 representation.
49
50 value() without arguments requires that every variable in the tree
51 contains a defined value attribute. Please note that this refers to
52 every variable object, not just every named variable.
53
54 value() with one argument sets the object's value if you're dealing
55 with Variables or Constants. In case of operators, a call with one
56 argument will assume that the argument is a hash reference. (see next
57 paragraph)
58
59 value() with named arguments (key/value pairs) associates variables in
60 the tree with the value-arguments if the corresponging key matches the
61 variable name. (Can one say this any more complicated?) Since version
62 0.132, an equivalent and valid syntax is to pass a single hash
63 reference instead of a list.
64
65 Example: $tree->value(x => 1, y => 2, z => 3, t => 0) assigns the value
66 1 to any occurrances of variables of the name "x", aso.
67
68 If a variable in the tree has no value set (and no argument of value
69 sets it temporarily), the call to value() returns undef.
70
71 Method signature
72 signature() returns a tree's signature.
73
74 In the context of Math::Symbolic, signatures are the list of variables
75 any given tree depends on. That means the tree "v*t+x" depends on the
76 variables v, t, and x. Thus, applying signature() on the tree that
77 would be parsed from above example yields the sorted list ('t', 'v',
78 'x').
79
80 Constants do not depend on any variables and therefore return the empty
81 list. Obviously, operators' dependencies vary.
82
83 Math::Symbolic::Variable objects, however, may have a slightly more
84 involved signature. By convention, Math::Symbolic variables depend on
85 themselves. That means their signature contains their own name. But
86 they can also depend on various other variables because variables
87 themselves can be viewed as placeholders for more compicated terms. For
88 example in mechanics, the acceleration of a particle depends on its
89 mass and the sum of all forces acting on it. So the variable
90 'acceleration' would have the signature ('acceleration', 'force1',
91 'force2',..., 'mass', 'time').
92
93 If you're just looking for a list of the names of all variables in the
94 tree, you should use the explicit_signature() method instead.
95
96 Method explicit_signature
97 explicit_signature() returns a lexicographically sorted list of
98 variable names in the tree.
99
100 See also: signature().
101
102 Method special
103 Optional argument: sets the object's special attribute. Returns the
104 object's special attribute.
105
106 Method to_string
107 Returns a string representation of the constant.
108
109 Method term_type
110 Returns the type of the term. (T_CONSTANT)
111
113 Please send feedback, bug reports, and support requests to the
114 Math::Symbolic support mailing list: math-symbolic-support at lists dot
115 sourceforge dot net. Please consider letting us know how you use
116 Math::Symbolic. Thank you.
117
118 If you're interested in helping with the development or extending the
119 module's functionality, please contact the developers' mailing list:
120 math-symbolic-develop at lists dot sourceforge dot net.
121
122 List of contributors:
123
124 Steffen Mueller, symbolic-module at steffen-mueller dot net
125 Stray Toaster, mwk at users dot sourceforge dot net
126 Oliver Ebenhoeh
127
129 New versions of this module can be found on http://steffen-mueller.net
130 or CPAN. The module development takes place on Sourceforge at
131 http://sourceforge.net/projects/math-symbolic/
132
133 Math::Symbolic
134
135
136
137perl v5.28.0 2018-07-14 Math::Symbolic::Constant(3)