NAME
Math::Symbolic::Custom::Collect - Collect up Math::Symbolic expressions
VERSION
Version 0.01
SYNOPSIS
use Math::Symbolic qw(:all);
use Math::Symbolic::Custom::Collect;
my $t1 = "0.125";
print "Output: ", parse_from_string($t1)->to_collected()->to_string(), "\n";
# Output: 1 / 8
my $t2 = "25/100";
print "Output: ", parse_from_string($t2)->to_collected()->to_string(), "\n";
# Output: 1 / 4
my $t3 = "((1/4)+(1/2))*3*x";
print "Output: ", parse_from_string($t3)->to_collected()->to_string(), "\n";
# Output: (9 * x) / 4
my $t4 = "1/(1-(1/x))";
print "Output: ", parse_from_string($t4)->to_collected()->to_string(), "\n";
# Output: x / (x - 1)
my $t5 = "sin(x^2+y)*sin(y+x^2)";
print "Output: ", parse_from_string($t5)->to_collected()->to_string(), "\n";
# Output: (sin((x ^ 2) + y)) ^ 2
my $t6 = "x + x^2 + 3*x^3 + 2*x - x^2";
print "Output: ", parse_from_string($t6)->to_collected()->to_string(), "\n";
# Output: (3 * x) + (3 * (x ^ 3))
my $t7 = "((1/(3*a))-(1/(3*b)))/((a/b)-(b/a))";
print "Output: ", parse_from_string($t7)->to_collected()->to_string(), "\n";
# Output: (b - a) / ((3 * (a ^ 2)) - (3 * (b ^ 2)))
DESCRIPTION
Provides "to_collected()" through the Math::Symbolic module extension class. "to_collected" performs the following operations on the inputted Math::Symbolic tree:-
Folds constants
Converts decimal numbers to rational numbers
Combines fractions
Expands brackets
Collects like terms
Cancels down
The result is often a more concise expression. However, because it does not (yet) factor the expression, the result is not always the simplest representation. Hence it is not offered as a simplify().
SEE ALSO
AUTHOR
Matt Johnson, <mjohnson at cpan.org>
BUGS
Please report any bugs or feature requests to bug-math-symbolic-custom-collect at rt.cpan.org
, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Math-Symbolic-Custom-Collect. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
ACKNOWLEDGEMENTS
Steffen Mueller, author of Math::Symbolic
LICENSE AND COPYRIGHT
This software is copyright (c) 2024 by Matt Johnson.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.