Math - constants and functions


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

the perlfunc manpage Perl built-in functions

PDL for scientific and bulk numeric data processing and display

the POSIX manpage

the Math::Complex manpage, the Math::Trig manpage, the Math::Quaternion manpage, the Math::Vectors manpage


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

atan2(number1, number2)

        perls atan2

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

fmod(number, number)

        POSIX fmod

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

clamp(number, min, max)

        Returns number between or equal min and max

odd(number)

        Returns 1 if number is odd otherwise 0

pro(number, number1, number2, ...)

        Returns the product of its arguments
        pro(1,2,3) == 1 * 2 * 3;
        my $product = pro(@array);

pow

Computes $x raised to the power $exponent .

        $ret = POSIX::pow( $x, $exponent );

You can also use the ** operator, see the perlop manpage.

random

Returns a pseudo-random number between 0 and 1.

        $ret = Math::random();

Returns a pseudo-random number between 0 and $number1.

        $ret = Math::random($number1);

Returns a pseudo-random number between number1 and number2.

        $ret = Math::random($number1, $number2);

round

Returns the value of $number rounded to the nearest integer

        $ret = Math::round($number);

Returns the value of $number rounded to the nearest float point number.

        $ret = round($number, $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.
        Returns -1 if number is lesser 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

the perlfunc manpage

the Math manpage

the Math::Algebra::Symbols manpage

the Math::Algebra::Symbols::Sum manpage

the Math::Algebra::Symbols::Term manpage

the Math::Algebra::SymbolsSum manpage

the Math::Algebra::SymbolsTerm manpage

Algorithms

the Math::Amoeba manpage

the Math::Approx manpage

the Math::Approx::Symbolic manpage

the Math::Base36 manpage

the Math::Base85 manpage

the Math::BaseArith manpage

the Math::BaseCalc manpage

the Math::BaseCnv manpage

the Math::Bezier manpage

the Math::Bezier::Convert manpage

the Math::Big manpage

the Math::Big::Factors manpage

the Math::BigFloat manpage

the Math::BigFloat::Trace manpage

the Math::BigInt manpage

the Math::BigInt::BitVect manpage

the Math::BigInt::Calc manpage

the Math::BigInt::CalcEmu manpage

the Math::BigInt::Constant manpage

the Math::BigInt::FastCalc manpage

the Math::BigInt::GMP manpage

the Math::BigInt::Lite manpage

the Math::BigInt::Named manpage

the Math::BigInt::Named::English manpage

the Math::BigInt::Named::German manpage

the Math::BigInt::Pari manpage

the Math::BigInt::Random manpage

the Math::BigInt::Scalar manpage

the Math::BigInt::Trace manpage

the Math::BigIntFast manpage

the Math::BigInteger manpage

the Math::BigRat manpage

the Math::BigSimple manpage

the Math::BooleanEval manpage

the Math::Brent manpage

the Math::Business::BlackSch manpage

the Math::Business::BlackScholes manpage

the Math::Business::EMA manpage

the Math::Business::MACD manpage

the Math::Business::SMA manpage

the Math::CDF manpage

the Math::Calc::Euro manpage

the Math::Calc::Units manpage

the Math::Calc::Units::Compute manpage

the Math::Calc::Units::Convert manpage

the Math::Calc::Units::Convert::Base manpage

the Math::Calc::Units::Convert::Base2Metric manpage

the Math::Calc::Units::Convert::Byte manpage

the Math::Calc::Units::Convert::Combo manpage

the Math::Calc::Units::Convert::Date manpage

the Math::Calc::Units::Convert::Distance manpage

the Math::Calc::Units::Convert::Metric manpage

the Math::Calc::Units::Convert::Multi manpage

the Math::Calc::Units::Convert::Time manpage

the Math::Calc::Units::Grammar manpage

the Math::Calc::Units::Rank manpage

the Math::Calculator manpage

the Math::Calculus::Differentiate manpage

the Math::Calculus::NewtonRaphson manpage

the Math::Calculus::TaylorEquivalent manpage

the Math::Calculus::TaylorSeries manpage

the Math::CatmullRom manpage

the Math::Cephes manpage

the Math::Cephes::Complex manpage

the Math::Cephes::Fraction manpage

the Math::Cephes::Matrix manpage

the Math::Cephes::Polynomial manpage

the Math::Color manpage

the Math::ColorRGBA manpage

the Math::Combinatorics manpage

Complex

the Math::Complex manpage

the Math::ConvexHull manpage

the Math::Counting manpage

the Math::Currency manpage

the Math::Currency::GBP manpage

the Math::Currency::JPY manpage

the Math::Curve::Hilbert manpage

the Math::Derivative manpage

the Math::ES manpage

the Math::ErrorPropagation manpage

the Math::Evol manpage

the Math::Expr manpage

the Math::Expr::FormulaDB manpage

the Math::Expr::MatchSet manpage

the Math::Expr::Node manpage

the Math::Expr::Num manpage

the Math::Expr::Opp manpage

the Math::Expr::OpperationDB manpage

the Math::Expr::Rule manpage

the Math::Expr::TypeDB manpage

the Math::Expr::Var manpage

the Math::Expr::VarSet manpage

Expression

the Math::Expression manpage

the Math::FFT manpage

the Math::FFTW manpage

the Math::Factor::XS manpage

the Math::Fibonacci manpage

the Math::Fibonacci::Phi manpage

the Math::Financial manpage

the Math::FitRect manpage

the Math::FixedPrecision manpage

the Math::Fleximal manpage

the Math::Fortran manpage

Fourier

the Math::Fourier manpage

Fractal

the Math::Fractal::Curve manpage

the Math::Fractal::DLA manpage

the Math::Fractal::DLA::Explode manpage

the Math::Fractal::DLA::GrowUp manpage

the Math::Fractal::DLA::Race2Center manpage

the Math::Fractal::DLA::Surrounding manpage

the Math::Fractal::Mandelbrot manpage

the Math::Fraction manpage

the Math::FractionDemo manpage

the Math::FresnalZone manpage

the Math::FresnelZone manpage

the Math::Function::Roots manpage

the Math::GAP manpage

the Math::GMP manpage

the Math::GMPf manpage

the Math::GMPq manpage

the Math::GMPz manpage

the Math::GMatrix manpage

the Math::GSL manpage

the Math::GammaFunction manpage

Geometry

the Math::Geometry manpage

the Math::Geometry::GPC manpage

the Math::Geometry::Planar manpage

the Math::Geometry::Planar::GPC manpage

the Math::Geometry::Planar::GPC::Inherit manpage

the Math::Geometry::Planar::GPC::Polygon manpage

the Math::Geometry::Planar::Offset manpage

the Math::Gradient manpage

the Math::GrahamFunction manpage

the Math::GrahamFunction::Object manpage

the Math::GrahamFunction::SqFacts manpage

the Math::GrahamFunction::SqFacts::Dipole manpage

the Math::Group::Thompson manpage

the Math::Gsl manpage

the Math::Gsl::Polynomial manpage

the Math::Gsl::Sf manpage

the Math::HashSum manpage

the Math::Int64 manpage

Integral

the Math::Integral manpage

the Math::Integral::Romberg manpage

the Math::Interpolate manpage

the Math::Interpolator manpage

the Math::Interpolator::Knot manpage

the Math::Interpolator::Linear manpage

the Math::Interpolator::Robust manpage

the Math::Interpolator::Source manpage

the Math::Intersection::StraightLine manpage

the Math::Interval manpage

the Math::IntervalSearch manpage

the Math::LP manpage

the Math::LP::Constraint manpage

the Math::LP::LinearCombination manpage

the Math::LP::Object manpage

the Math::LP::Solve manpage

the Math::LP::Variable manpage

the Math::Libm manpage

the Math::LinearCombination manpage

the Math::LinearProg manpage

the Math::LogRand manpage

Logic

the Math::Logic manpage

the Math::Logic::Predicate manpage

the Math::Logic::Ternary manpage

the Math::MPFR manpage

the Math::MVPoly manpage

the Math::MVPoly::Ideal manpage

the Math::MVPoly::Integer manpage

the Math::MVPoly::Monomial manpage

the Math::MVPoly::Parser manpage

the Math::MVPoly::Polynomial manpage

the Math::Macopt manpage

the Math::MagicSquare manpage

the Math::MagicSquare::Generator manpage

the Math::Matlab manpage

the Math::Matlab::Engine manpage

the Math::Matlab::Local manpage

the Math::Matlab::Pool manpage

the Math::Matlab::Remote manpage

the Math::Matlab::Server manpage

Matrix

the Math::Matrix manpage

the Math::Matrix::SVD manpage

the Math::MatrixBool manpage

the Math::MatrixCplx manpage

the Math::MatrixReal manpage

the Math::MatrixReal::Ext1 manpage

the Math::MatrixSparse manpage

the Math::MultiplicationTable manpage

the Math::NoCarry manpage

the Math::Nocarry manpage

the Math::NumberCruncher manpage

Numbers

the Math::Numbers manpage

the Math::ODE manpage

the Math::Orthonormalize manpage

the Math::PRSG manpage

the Math::Pari manpage

the Math::PariBuild manpage

the Math::PartialOrder manpage

the Math::PartialOrder::Base manpage

the Math::PartialOrder::CEnum manpage

the Math::PartialOrder::CMasked manpage

the Math::PartialOrder::Caching manpage

the Math::PartialOrder::LRUCaching manpage

the Math::PartialOrder::Loader manpage

the Math::PartialOrder::Std manpage

the Math::Polygon manpage

the Math::Polygon::Calc manpage

the Math::Polygon::Clip manpage

the Math::Polygon::Surface manpage

the Math::Polygon::Transform manpage

the Math::Polyhedra manpage

Polynom

the Math::Polynom manpage

the Math::Polynomial manpage

the Math::Polynomial::Solve manpage

the Math::Prime::XS manpage

the Math::Project manpage

the Math::Project3D manpage

the Math::Project3D::Function manpage

the Math::Project3D::Plot manpage

the Math::Quaternion manpage

the Math::RPN manpage

the Math::Rand48 manpage

Random

the Math::Random manpage

the Math::Random::AcceptReject manpage

the Math::Random::Brownian manpage

the Math::Random::Cauchy manpage

the Math::Random::MT manpage

the Math::Random::MT::Auto manpage

the Math::Random::MT::Auto::Range manpage

the Math::Random::MT::Auto::Util manpage

the Math::Random::OO manpage

the Math::Random::OO::Bootstrap manpage

the Math::Random::OO::Normal manpage

the Math::Random::OO::Uniform manpage

the Math::Random::OO::UniformInt manpage

the Math::Random::TT800 manpage

the Math::RandomOrg manpage

the Math::Roman manpage

the Math::Rotation manpage

the Math::Round manpage

the Math::Round::Var manpage

the Math::RungeKutta manpage

the Math::SO3 manpage

the Math::Sequence manpage

the Math::Series manpage

the Math::SigFigs manpage

Simple

the Math::Simple manpage

the Math::SimpleInterest manpage

the Math::SimpleVariable manpage

Music::is::Math

the Math::Sparse::Matrix manpage

the Math::Sparse::Vector manpage

the Math::SparseMatrix manpage

the Math::SparseVector manpage

the Math::Spline manpage

the Math::Stat manpage

String

the Math::String manpage

the Math::String::Charset manpage

the Math::String::Charset::Grouped manpage

the Math::String::Charset::Nested manpage

the Math::String::Charset::Wordlist manpage

the Math::String::Sequence manpage

Symbolic

the Math::Symbolic manpage

the Math::Symbolic::AuxFunctions manpage

the Math::Symbolic::Base manpage

the Math::Symbolic::Compiler manpage

the Math::Symbolic::Constant manpage

the Math::Symbolic::Custom manpage

the Math::Symbolic::Custom::Base manpage

the Math::Symbolic::Custom::CCompiler manpage

the Math::Symbolic::Custom::Contains manpage

the Math::Symbolic::Custom::DefaultDumpers manpage

the Math::Symbolic::Custom::DefaultMods manpage

the Math::Symbolic::Custom::DefaultTests manpage

the Math::Symbolic::Custom::ErrorPropagation manpage

the Math::Symbolic::Custom::LaTeXDumper manpage

the Math::Symbolic::Custom::Pattern manpage

the Math::Symbolic::Custom::Pattern::Export manpage

the Math::Symbolic::Custom::Simplification manpage

the Math::Symbolic::Custom::Transformation manpage

the Math::Symbolic::Custom::Transformation::Group manpage

the Math::Symbolic::Derivative manpage

the Math::Symbolic::ExportConstants manpage

the Math::Symbolic::MiscAlgebra manpage

the Math::Symbolic::MiscCalculus manpage

the Math::Symbolic::Operator manpage

the Math::Symbolic::Parser manpage

the Math::Symbolic::Parser::Precompiled manpage

the Math::Symbolic::Parser::Yapp manpage

the Math::Symbolic::Variable manpage

the Math::Symbolic::VectorCalculus manpage

the Math::SymbolicX::BigNum manpage

the Math::SymbolicX::Calculator manpage

the Math::SymbolicX::Calculator::Command manpage

the Math::SymbolicX::Calculator::Command::Assignment manpage

the Math::SymbolicX::Calculator::Command::DerivativeApplication manpage

the Math::SymbolicX::Calculator::Command::Insertion manpage

the Math::SymbolicX::Calculator::Command::Transformation manpage

the Math::SymbolicX::Calculator::Interface manpage

the Math::SymbolicX::Calculator::Interface::Shell manpage

the Math::SymbolicX::Calculator::Interface::Web manpage

the Math::SymbolicX::Calculator::Interface::Web::Server manpage

the Math::SymbolicX::Complex manpage

the Math::SymbolicX::Error manpage

the Math::SymbolicX::Inline manpage

the Math::SymbolicX::NoSimplification manpage

the Math::SymbolicX::ParserExtensionFactory manpage

the Math::SymbolicX::Statistics::Distributions manpage

the Math::Systems manpage

Taylor

the Math::Taylor manpage

the Math::Telephony::ErlangB manpage

the Math::Telephony::ErlangC manpage

the Math::TotalBuilder manpage

the Math::TotalBuilder::Common manpage

the Math::TriangularNumbers manpage

Trig

the Math::Trig manpage

the Math::Trig::Degree manpage

the Math::Trig::Gradian manpage

the Math::Trig::Radian manpage

the Math::Trig::Units manpage

the Math::TrulyRandom manpage

the Math::Units manpage

the Math::Units::PhysicalValue manpage

Vector

the Math::Vec manpage

the Math::Vec2 manpage

the Math::Vec3 manpage

the Math::VecStat manpage

the Math::Vector manpage

the Math::Vectors manpage

the Math::Vector::SortIndexes manpage

the Math::VectorReal manpage

the Math::Zap::Vector manpage

the Math::Zap::Vector2 manpage

ematica

the Math::Volume::Rotational manpage

the Math::WalshTransform manpage

the Math::XOR manpage

the Math::Zap::Color manpage

the Math::Zap::Cube manpage

the Math::Zap::Draw manpage

the Math::Zap::Exports manpage

the Math::Zap::Line2 manpage

the Math::Zap::Matrix manpage

the Math::Zap::Matrix2 manpage

the Math::Zap::Rectangle manpage

the Math::Zap::Triangle manpage

the Math::Zap::Triangle2 manpage

the Math::Zap::Unique manpage

the Math::ematica manpage


SEE ALSO

the perlfunc manpage Perl built-in functions

PDL for scientific and bulk numeric data processing and display

the POSIX manpage

the Math::Complex manpage, the Math::Trig manpage, the Math::Quaternion manpage, the Math::Vectors manpage


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.