1Math::Symbolic::MiscAlgUesberra(C3o)ntributed Perl DocumMeanttha:t:iSoynmbolic::MiscAlgebra(3)
2
3
4
6 Math::Symbolic::MiscAlgebra - Miscellaneous algebra routines like det()
7
9 use Math::Symbolic qw/:all/;
10 use Math::Symbolic::MiscAlgebra qw/:all/; # not loaded by Math::Symbolic
11
12 @matrix = (['x*y', 'z*x', 'y*z'],['x', 'z', 'z'],['x', 'x', 'y']);
13 $det = det @matrix;
14
15 @vector = ('x', 'y', 'z');
16 $solution = solve_linear(\@matrix, \@vector);
17
19 This module provides several subroutines related to algebra such as
20 computing the determinant of quadratic matrices, solving linear
21 equation systems and computation of Bell Polynomials.
22
23 Please note that the code herein may or may not be refactored into the
24 OO-interface of the Math::Symbolic module in the future.
25
26 EXPORT
27 None by default.
28
29 You may choose to have any of the following routines exported to the
30 calling namespace. ':all' tag exports all of the following:
31
32 det
33 linear_solve
34 bell_polynomial
35
37 det
38 det() computes the determinant of a matrix of Math::Symbolic trees (or
39 strings that can be parsed as such). First argument must be a literal
40 array: "det @matrix", where @matrix is an n x n matrix.
41
42 Please note that calculating determinants of matrices using the
43 straightforward Laplace algorithm is a slow (O(n!)) operation. This
44 implementation cannot make use of the various optimizations resulting
45 from the determinant properties since we are dealing with symbolic
46 matrix elements. If you have a matrix of reals, it is strongly
47 suggested that you use Math::MatrixReal or Math::Pari to get the
48 determinant which can be calculated using LR decomposition much faster.
49
50 On a related note: Calculating the determinant of a 20x20 matrix would
51 take over 77146 years if your Perl could do 1 million calculations per
52 second. Given that we're talking about several method calls per
53 calculation, that's much more than todays computers could do. On the
54 other hand, if you'd be using this straightforward algorithm with
55 numbers only and in C, you might be done in 26 years alright, so please
56 go for the smarter route (better algorithm) instead if you have numbers
57 only.
58
59 linear_solve
60 Calculates the solutions x (vector) of a linear equation system of the
61 form "Ax = b" with "A" being a matrix, "b" a vector and the solution
62 "x" a vector. Due to implementation limitations, "A" must be a
63 quadratic matrix and "b" must have a dimension that is equivalent to
64 that of "A". Furthermore, the determinant of "A" must be non-zero. The
65 algorithm used is devised from Cramer's Rule and thus inefficient. The
66 preferred algorithm for this task is Gaussian Elimination. If you have
67 a matrix and a vector of real numbers, please consider using either
68 Math::MatrixReal or Math::Pari instead.
69
70 First argument must be a reference to a matrix (array of arrays) of
71 symbolic terms, second argument must be a reference to a vector (array)
72 of symbolic terms. Strings will be automatically converted to
73 Math::Symbolic trees. Returns a reference to the solution vector.
74
75 bell_polynomial
76 This functions returns the nth Bell Polynomial. It uses memoization for
77 speed increase.
78
79 First argument is the n. Second (optional) argument is the variable or
80 variable name to use in the polynomial. Defaults to 'x'.
81
82 The Bell Polynomial is defined as follows:
83
84 phi_0 (x) = 1
85 phi_n+1(x) = x * ( phi_n(x) + partial_derivative( phi_n(x), x ) )
86
87 Bell Polynomials are Exponential Polynimals with phi_n(1) = the nth
88 bell number. Please refer to the bell_number() function in the
89 Math::Symbolic::AuxFunctions module for a method of generating these
90 numbers.
91
93 Please send feedback, bug reports, and support requests to the
94 Math::Symbolic support mailing list: math-symbolic-support at lists dot
95 sourceforge dot net. Please consider letting us know how you use
96 Math::Symbolic. Thank you.
97
98 If you're interested in helping with the development or extending the
99 module's functionality, please contact the developers' mailing list:
100 math-symbolic-develop at lists dot sourceforge dot net.
101
102 List of contributors:
103
104 Steffen Mueller, symbolic-module at steffen-mueller dot net
105 Stray Toaster, mwk at users dot sourceforge dot net
106 Oliver Ebenhoeh
107
109 New versions of this module can be found on http://steffen-mueller.net
110 or CPAN. The module development takes place on Sourceforge at
111 http://sourceforge.net/projects/math-symbolic/
112
113 Math::Symbolic
114
115
116
117perl v5.28.0 2018-07-14 Math::Symbolic::MiscAlgebra(3)