NAME
Math - constants and functions
SYNOPSIS
use Math;
printf "2.71828182845905 = %s\n", E;
printf "1.5707963267949 = %s\n", PI1_2;
printf "1 = %s\n", round(0.5);
printf "1 = %s\n", ceil(0.5);
printf "0 = %s\n", floor(0.5);
or
use Math ();
printf "%s\n", Math::PI;
printf "%s\n", Math::round(0.5);
SEE ALSO
perlfunc
POSIX
Math::Complex, Math::Trig, Math::Quaternion
Math::Color, Math::Image, Math::Vec2, Math::Vec3, Math::Rotation
Constants
E
Euler's constant, e, approximately 2.718
LN10
Natural logarithm of 10, approximately 2.302
LN2
Natural logarithm of 2, approximately 0.693
PI
Ratio of the circumference of a circle to its diameter, approximately 3.1415 or atan2( 0, -1 ).
PI1_2 == PI * 1/2
SQRT1_2
square root of 1/2, approximately 0.707
SQRT2
square root of 2, approximately 1.414
Functions
Note number, number1, number2, base, and exponent indicate any expression with a scalar value.
abs(number)
Returns the absolute value of number
acos(number)
Returns the arc cosine (in radians) of number
asin(number)
Returns the arc sine (in radians) of number
atan(number)
Returns the arc tangent (in radians) of number
ceil(number)
Returns the least integer greater than or equal to number
cos(number)
Returns the cosine of number where number is expressed in radians
exp(number)
Returns e, to the power of number (i.e. enumber)
even(number)
Returns 1 if number is even otherwise 0
floor(number)
Returns the greatest integer less than or equal to its argument
log(number)
Returns the natural logarithm (base e) of number
log10(number)
Returns the logarithm (base 10) of number
min(number1, number2)
Returns the lesser of number1 and number2
max(number1, number2)
Returns the greater of number1 and number2
minmax(min, number, max)
minmax(number, min, max)
Returns number between or equal min and max
odd(number)
Returns 1 if number is odd otherwise 0
pow(base, exponent)
Returns base to the exponent power (i.e. base exponent)
$base ** $exponent == pow($base, $exponent);
pro(number, number1, number2, ...)
Returns the product of its arguments
pro(1,2,3) == 1 * 2 * 3;
my $product = pro(@array);
random()
Returns a pseudo-random number between 0 and 1.
random(number)
Returns a pseudo-random number between 0 and number.
random(number1, number2)
Returns a pseudo-random number between number1 and number2.
round(number)
Returns the value of number rounded to the nearest integer
round(number1, digits)
round(0.123456, 2) == 0.12;
round(50, -2) == 100;
round(5, -1) == 10;
round(0.5) == 1;
round(0.05, 1) == 0.1;
round(0.005, 2) == 0.01;
sig(number)
Returns 1 if number is greater 0 otherwise -1
sin(number)
Returns the sine of number where number is expressed in radians
sqrt(number)
Returns the square root of its argument
sum(number, number1, number2, ...)
Returns the sum of its arguments
sum(1..3) == 1 + 2 + 3;
my $sum = sum(@array);
tan(number)
Returns the tangent of number, where number is expressed in radians
MODULES
Algebra
perlfunc
Math
Math::Algebra::Symbols
Math::Algebra::Symbols::Sum
Math::Algebra::Symbols::Term
Math::Algebra::SymbolsSum
Math::Algebra::SymbolsTerm
Algorithms
Math::Amoeba
Math::Approx
Math::Approx::Symbolic
Math::Base36
Math::Base85
Math::BaseArith
Math::BaseCalc
Math::BaseCnv
Math::Bezier
Math::Bezier::Convert
Math::Big
Math::Big::Factors
Math::BigFloat
Math::BigFloat::Trace
Math::BigInt
Math::BigInt::BitVect
Math::BigInt::Calc
Math::BigInt::CalcEmu
Math::BigInt::Constant
Math::BigInt::FastCalc
Math::BigInt::GMP
Math::BigInt::Lite
Math::BigInt::Named
Math::BigInt::Named::English
Math::BigInt::Named::German
Math::BigInt::Pari
Math::BigInt::Random
Math::BigInt::Scalar
Math::BigInt::Trace
Math::BigIntFast
Math::BigInteger
Math::BigRat
Math::BigSimple
Math::BooleanEval
Math::Brent
Math::Business::BlackSch
Math::Business::BlackScholes
Math::Business::EMA
Math::Business::MACD
Math::Business::SMA
Math::CDF
Math::Calc::Euro
Math::Calc::Units
Math::Calc::Units::Compute
Math::Calc::Units::Convert
Math::Calc::Units::Convert::Base
Math::Calc::Units::Convert::Base2Metric
Math::Calc::Units::Convert::Byte
Math::Calc::Units::Convert::Combo
Math::Calc::Units::Convert::Date
Math::Calc::Units::Convert::Distance
Math::Calc::Units::Convert::Metric
Math::Calc::Units::Convert::Multi
Math::Calc::Units::Convert::Time
Math::Calc::Units::Grammar
Math::Calc::Units::Rank
Math::Calculator
Math::Calculus::Differentiate
Math::Calculus::NewtonRaphson
Math::Calculus::TaylorEquivalent
Math::Calculus::TaylorSeries
Math::CatmullRom
Math::Cephes
Math::Cephes::Complex
Math::Cephes::Fraction
Math::Cephes::Matrix
Math::Cephes::Polynomial
Math::Color
Math::ColorRGBA
Math::Combinatorics
Complex
Math::Complex
Math::ConvexHull
Math::Counting
Math::Currency
Math::Currency::GBP
Math::Currency::JPY
Math::Curve::Hilbert
Math::Derivative
Math::ES
Math::ErrorPropagation
Math::Evol
Math::Expr
Math::Expr::FormulaDB
Math::Expr::MatchSet
Math::Expr::Node
Math::Expr::Num
Math::Expr::Opp
Math::Expr::OpperationDB
Math::Expr::Rule
Math::Expr::TypeDB
Math::Expr::Var
Math::Expr::VarSet
Expression
Math::Expression
Math::FFT
Math::FFTW
Math::Factor::XS
Math::Fibonacci
Math::Fibonacci::Phi
Math::Financial
Math::FitRect
Math::FixedPrecision
Math::Fleximal
Math::Fortran
Fourier
Math::Fourier
Fractal
Math::Fractal::Curve
Math::Fractal::DLA
Math::Fractal::DLA::Explode
Math::Fractal::DLA::GrowUp
Math::Fractal::DLA::Race2Center
Math::Fractal::DLA::Surrounding
Math::Fractal::Mandelbrot
Math::Fraction
Math::FractionDemo
Math::FresnalZone
Math::FresnelZone
Math::Function::Roots
Math::GAP
Math::GMP
Math::GMPf
Math::GMPq
Math::GMPz
Math::GMatrix
Math::GSL
Math::GammaFunction
Geometry
Math::Geometry
Math::Geometry::GPC
Math::Geometry::Planar
Math::Geometry::Planar::GPC
Math::Geometry::Planar::GPC::Inherit
Math::Geometry::Planar::GPC::Polygon
Math::Geometry::Planar::Offset
Math::Gradient
Math::GrahamFunction
Math::GrahamFunction::Object
Math::GrahamFunction::SqFacts
Math::GrahamFunction::SqFacts::Dipole
Math::Group::Thompson
Math::Gsl
Math::Gsl::Polynomial
Math::Gsl::Sf
Math::HashSum
Math::Int64
Integral
Math::Integral
Math::Integral::Romberg
Math::Interpolate
Math::Interpolator
Math::Interpolator::Knot
Math::Interpolator::Linear
Math::Interpolator::Robust
Math::Interpolator::Source
Math::Intersection::StraightLine
Math::Interval
Math::IntervalSearch
Math::LP
Math::LP::Constraint
Math::LP::LinearCombination
Math::LP::Object
Math::LP::Solve
Math::LP::Variable
Math::Libm
Math::LinearCombination
Math::LinearProg
Math::LogRand
Logic
Math::Logic
Math::Logic::Predicate
Math::Logic::Ternary
Math::MPFR
Math::MVPoly
Math::MVPoly::Ideal
Math::MVPoly::Integer
Math::MVPoly::Monomial
Math::MVPoly::Parser
Math::MVPoly::Polynomial
Math::Macopt
Math::MagicSquare
Math::MagicSquare::Generator
Math::Matlab
Math::Matlab::Engine
Math::Matlab::Local
Math::Matlab::Pool
Math::Matlab::Remote
Math::Matlab::Server
Matrix
Math::Matrix
Math::Matrix::SVD
Math::MatrixBool
Math::MatrixCplx
Math::MatrixReal
Math::MatrixReal::Ext1
Math::MatrixSparse
Math::MultiplicationTable
Math::NoCarry
Math::Nocarry
Math::NumberCruncher
Numbers
Math::Numbers
Math::ODE
Math::Orthonormalize
Math::PRSG
Math::Pari
Math::PariBuild
Math::PartialOrder
Math::PartialOrder::Base
Math::PartialOrder::CEnum
Math::PartialOrder::CMasked
Math::PartialOrder::Caching
Math::PartialOrder::LRUCaching
Math::PartialOrder::Loader
Math::PartialOrder::Std
Math::Polygon
Math::Polygon::Calc
Math::Polygon::Clip
Math::Polygon::Surface
Math::Polygon::Transform
Math::Polyhedra
Polynom
Math::Polynom
Math::Polynomial
Math::Polynomial::Solve
Math::Prime::XS
Math::Project
Math::Project3D
Math::Project3D::Function
Math::Project3D::Plot
Math::Quaternion
Math::RPN
Math::Rand48
Random
Math::Random
Math::Random::AcceptReject
Math::Random::Brownian
Math::Random::Cauchy
Math::Random::MT
Math::Random::MT::Auto
Math::Random::MT::Auto::Range
Math::Random::MT::Auto::Util
Math::Random::OO
Math::Random::OO::Bootstrap
Math::Random::OO::Normal
Math::Random::OO::Uniform
Math::Random::OO::UniformInt
Math::Random::TT800
Math::RandomOrg
Math::Roman
Math::Rotation
Math::Round
Math::Round::Var
Math::RungeKutta
Math::SO3
Math::Sequence
Math::Series
Math::SigFigs
Simple
Math::Simple
Math::SimpleInterest
Math::SimpleVariable
Math::Sparse::Matrix
Math::Sparse::Vector
Math::SparseMatrix
Math::SparseVector
Math::Spline
Math::Stat
String
Math::String
Math::String::Charset
Math::String::Charset::Grouped
Math::String::Charset::Nested
Math::String::Charset::Wordlist
Math::String::Sequence
Symbolic
Math::Symbolic
Math::Symbolic::AuxFunctions
Math::Symbolic::Base
Math::Symbolic::Compiler
Math::Symbolic::Constant
Math::Symbolic::Custom
Math::Symbolic::Custom::Base
Math::Symbolic::Custom::CCompiler
Math::Symbolic::Custom::Contains
Math::Symbolic::Custom::DefaultDumpers
Math::Symbolic::Custom::DefaultMods
Math::Symbolic::Custom::DefaultTests
Math::Symbolic::Custom::ErrorPropagation
Math::Symbolic::Custom::LaTeXDumper
Math::Symbolic::Custom::Pattern
Math::Symbolic::Custom::Pattern::Export
Math::Symbolic::Custom::Simplification
Math::Symbolic::Custom::Transformation
Math::Symbolic::Custom::Transformation::Group
Math::Symbolic::Derivative
Math::Symbolic::ExportConstants
Math::Symbolic::MiscAlgebra
Math::Symbolic::MiscCalculus
Math::Symbolic::Operator
Math::Symbolic::Parser
Math::Symbolic::Parser::Precompiled
Math::Symbolic::Parser::Yapp
Math::Symbolic::Variable
Math::Symbolic::VectorCalculus
Math::SymbolicX::BigNum
Math::SymbolicX::Calculator
Math::SymbolicX::Calculator::Command
Math::SymbolicX::Calculator::Command::Assignment
Math::SymbolicX::Calculator::Command::DerivativeApplication
Math::SymbolicX::Calculator::Command::Insertion
Math::SymbolicX::Calculator::Command::Transformation
Math::SymbolicX::Calculator::Interface
Math::SymbolicX::Calculator::Interface::Shell
Math::SymbolicX::Calculator::Interface::Web
Math::SymbolicX::Calculator::Interface::Web::Server
Math::SymbolicX::Complex
Math::SymbolicX::Error
Math::SymbolicX::Inline
Math::SymbolicX::NoSimplification
Math::SymbolicX::ParserExtensionFactory
Math::SymbolicX::Statistics::Distributions
Math::Systems
Taylor
Math::Taylor
Math::Telephony::ErlangB
Math::Telephony::ErlangC
Math::TotalBuilder
Math::TotalBuilder::Common
Math::TriangularNumbers
Trig
Math::Trig
Math::Trig::Degree
Math::Trig::Gradian
Math::Trig::Radian
Math::Trig::Units
Math::TrulyRandom
Math::Units
Math::Units::PhysicalValue
Vector
Math::Vec
Math::Vec2
Math::Vec3
Math::VecStat
Math::Vector
Math::Vector::SortIndexes
Math::VectorReal
Math::Zap::Vector
Math::Zap::Vector2
ematica
Math::Volume::Rotational
Math::WalshTransform
Math::XOR
Math::Zap::Color
Math::Zap::Cube
Math::Zap::Draw
Math::Zap::Exports
Math::Zap::Line2
Math::Zap::Matrix
Math::Zap::Matrix2
Math::Zap::Rectangle
Math::Zap::Triangle
Math::Zap::Triangle2
Math::Zap::Unique
Math::ematica
SEE ALSO
POSIX
Math::Complex, Math::Trig, Math::Quaternion
Math::Color, Math::Image, Math::Vec2, Math::Vec3, Math::Rotation
BUGS & SUGGESTIONS
If you run into a miscalculation, need some sort of feature or an additional holiday, or if you know of any new changes to the funky math, please drop the author a note.
ARRANGED BY
Holger Seelig holger.seelig@yahoo.de
COPYRIGHT
This is free software; you can redistribute it and/or modify it under the same terms as Perl itself.