NAME
Math::NumSeq::Expression  mathematical expression values
SYNOPSIS
use Math::NumSeq::Expression;
my $seq = Math::NumSeq::Expression>new (expression => '2*i+1');
my ($i, $value) = $seq>next;
DESCRIPTION
A string expression evaluated at i=0, 1, 2, etc, by a choice of evaluator modules.
This is designed to take expression strings from user input, though could be used for something quick from program code too.
Perl
The default expression_evaluator => 'Perl'
evaluates with Perl itself. This is always available. Expressions are with the Safe
module to restrict to arithmetic.
The i value is in a $i
variable and an i
function. The i
function is prototyped like a constant.
i+1
2*$i  2
The functions made available include
atan2 sin cos exp log \ Perl builtins
sqrt rand /
min max List::Util
floor ceil POSIX module
cbrt hypot erf erfc expm1 \
j0 j1 jn lgamma_r log10  Math::Libm
log1p pow rint y0 y1 yn /
tan asin acos atan \
csc cosec sec cot cotan  Math::Trig
acsc acosec asec acot acotan 
sinh cosh tanh 
csch cosech sech coth cotanh 
asinh acosh atanh 
acsch acosech asech acoth acotanh /
MathSymbolic
expression_evaluator => 'MS'
selects the Math::Symbolic
module, if available.
The expression should use a single variable, which can be any name, and takes the $i
index in the sequence.
The usual Math::Symbolic
simplify()
is applied to perhaps reduce the expression a bit, then its to_sub()
for actual evaluation.
MathExpressionEvaluator
expression_evaluator => 'MEE'
selects the Math::Expression::Evaluator
module, if available.
The expression should use a single input variable, which can be any name, and takes the $i
index in the sequence. Temporary variables can be assigned to, as for instance
t=2*i; t^2
The expression is compiled with the Math::Expression::Evaluator
compiled()
method for actual evaluation.
LanguageExpr
expression_evaluator => 'LE'
selects the Language::Expr
module, if available. See Language::Expr::Manual::Syntax for its expression syntax.
The expression should use a single variable, of any name, which will be the $i
index in the sequence.
The expression is compiled with Language::Expr::Compiler::Perl for evaluation.
FUNCTIONS
See "FUNCTIONS" in Math::NumSeq for the behaviour common to all path classes.
$seq = Math::NumSeq::Expression>new (radix => $r, modulus => $d)

Create and return a new sequence object.
$value = $seq>ith($i)

Return the
expression
evaluated at$i
.
BUGS
Safe.pm
seems a bit of a slowdown. Is that right or is it supposed to validate ops during the eval which compiles a subr?
SEE ALSO
HOME PAGE
http://user42.tuxfamily.org/mathnumseq/index.html
LICENSE
Copyright 2010, 2011 Kevin Ryde
MathNumSeq is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
MathNumSeq is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with MathNumSeq. If not, see <http://www.gnu.org/licenses/>.