Math::...Algebra(3pm)
πΈ Math::...Algebra(3pm) πΈ
okay bestie, welcome to the User Contributed Perl Documentation entry for Math::Symbolic::MiscAlgebra β yes the man page header shortens the name all cute like that, don't @ me. pull up a chair, we're doing algebra π
β¨ NAME β¨
Math::Symbolic::MiscAlgebra β miscellaneous algebra routines, like det(). that's it, that's the name π
π SYNOPSIS π
use Math::Symbolic qw/:all/;
use Math::Symbolic::MiscAlgebra qw/:all/; # not loaded by Math::Symbolic
@matrix = (['x*y', 'z*x', 'y*z'],['x', 'z', 'z'],['x', 'x', 'y']);
$det = det @matrix;
@vector = ('x', 'y', 'z');
$solution = solve_linear(\@matrix, \@vector);
π DESCRIPTION π
so this module hands you a lil bundle of subroutines that are all about algebra β like computing the determinant of quadratic matrices, solving linear equation systems, and computing Bell Polynomials. iconic behaviour tbh π«Ά
heads up though: the code in here may or may not get refactored into the OO-interface of the Math::Symbolic module at some point in the future. so like, no promises, luv u π
π EXPORT π
None by default. nada. zero. the void. π
but you can choose to have any of these routines exported into the calling namespace if you want. and the :all tag exports all of the following:
det
linear_solve
bell_polynomial
π₯ SUBROUTINES π₯
β det
det() computes the determinant of a matrix of Math::Symbolic trees (or strings that can be parsed as such, slay). the first argument must be a literal array: det @matrix, where @matrix is an n x n matrix.
β οΈ ngl bestie, real talk: calculating determinants of matrices using the straightforward Laplace algorithm is a slow (O(n!)) operation. like, O(n!). this implementation also cannot make use of the various optimizations that come from the determinant properties, because we're dealing with symbolic matrix elements. so if you've got a matrix of reals, it is strongly suggested that you useMath::MatrixRealorMath::Parito get the determinant instead β those can calculate it using LR decomposition, which is much faster. periodt.
and on a related note, because the numbers here are genuinely unhinged: calculating the determinant of a 20x20 matrix would take over 77146 years if your Perl could do 1 million calculations per second. π and given that we're talking about several method calls per calculation, that's much more than today's computers could do. on the other hand, if you were using this straightforward algorithm with numbers only and in C, you might be done in 26 years β alright β so please go for the smarter route (better algorithm) instead if you have numbers only. k byeee π¦
π linear_solve
Calculates the solutions x (vector) of a linear equation system of the form Ax = b, with A being a matrix, b a vector, and the solution x a vector. the way that math works β¨
Due to implementation limitations:
Amust be a quadratic matrixbmust have a dimension that is equivalent to that ofA- furthermore, the determinant of
Amust be non-zero
The algorithm used is devised from Cramer's Rule and is therefore inefficient. the preferred algorithm for this task is Gaussian Elimination. so if you have a matrix and a vector of real numbers, please consider using either Math::MatrixReal or Math::Pari instead. i'm just the messenger π
First argument must be a reference to a matrix (array of arrays) of symbolic terms, and the second argument must be a reference to a vector (array) of symbolic terms. Strings will be automatically converted to Math::Symbolic trees, no extra work from you. Returns a reference to the solution vector. π
π¦ bell_polynomial
This function returns the nth Bell Polynomial. it uses memoization for a speed increase, because we're efficient like that β‘
First argument is the n. Second (optional) argument is the variable or variable name to use in the polynomial. it defaults to 'x'.
The Bell Polynomial is defined as follows:
phi_0 (x) = 1
phi_n+1(x) = x * ( phi_n(x) + partial_derivative( phi_n(x), x ) )
Bell Polynomials are Exponential Polynimals (sic, we keep it real in this house π) with phi_n(1) = the nth bell number. Please refer to the bell_number() function in the Math::Symbolic::AuxFunctions module for a method of generating these numbers. go lil numbers go π
π AUTHOR π
Please send feedback, bug reports, and support requests to the Math::Symbolic support mailing list: math-symbolic-support at lists dot sourceforge dot net. and honestly? please consider letting us know how you use Math::Symbolic. Thank you. π«Ά
If you're interested in helping with the development or extending the module's functionality, please contact the developers' mailing list: math-symbolic-develop at lists dot sourceforge dot net.
List of contributors β legends, every single one π:
Steffen MΓΌller, symbolic-module at steffen-mueller dot net
Stray Toaster, mwk at users dot sourceforge dot net
Oliver EbenhΓΆh
π SEE ALSO π
New versions of this module can be found on http://steffen-mueller.net or CPAN. The module development takes place on Sourceforge at http://sourceforge.net/projects/math-symbolic/
Math::Symbolic
and that's the whole page bestie, you ate it π
β this was perl v5.40.0, dated 2024-09-16, filed under Math::...Algebra(3pm) β go forth and compute those determinants (responsibly, with Math::MatrixReal) ππ
π¦ where this page comes from
- ubuntu resolute: libmath-symbolic-perl 0.613-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmath-symbolic-perl 0.613-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms