NAME

Math::Expression::Evaluator::Optimizer - Optimize M::E::E ASTs

SYNOPSIS

use Math::Expression::Evaluator;
my $m = Math::Expression::Evaluator->new("2 + 4*f");
$m->optimize();
for (0..100){
    print $m->val({f => $_}), "\n";
}

DESCRIPTION

Math::Expression::Evaluator::Optimizer performs simple optimizations on the abstract syntax tree from Math::Expression::Evaluator.

You should not use this module directly, but interface it via Math::Expression::Evaluator.

The following optimizations are implemented:

  • Constant sub expressions: variable + 3 * 4 is simplfied to variable + 12.

  • Joining of constants in mixed constant/variable expressions: 2 + var + 3 is simplified to var + 5. Works only with sums and products (but internally a 2 - 3 + x is represented as 2 + (-3) + x, so it actually works with differences and divisions as well).

1 POD Error

The following errors were encountered while parsing the POD:

Around line 28:

=over without closing =back