NAME

Acme::ExtUtils::XSOne::Test::Calculator::Scientific - Scientific and advanced mathematical operations

SYNOPSIS

# Import specific functions
use Acme::ExtUtils::XSOne::Test::Calculator::Scientific qw(power sqrt_val factorial);

my $pow  = power(2, 10);    # 1024
my $sqrt = sqrt_val(16);    # 4
my $fact = factorial(5);    # 120

# Or use fully qualified names
use Acme::ExtUtils::XSOne::Test::Calculator;

my $log = Acme::ExtUtils::XSOne::Test::Calculator::Scientific::log_natural(10); # ~2.303

EXPORTABLE FUNCTIONS

All functions can be imported by name:

power sqrt_val cbrt_val nth_root log_natural log10_val log_base exp_val
factorial ipow safe_sqrt safe_log combination permutation

DESCRIPTION

This module provides scientific and advanced mathematical operations as part of the Acme::ExtUtils::XSOne::Test::Calculator distribution. All operations record their results in the shared calculation history.

FUNCTIONS

power

my $result = power($base, $exp);

Returns $base raised to the power of $exp.

sqrt_val

my $result = sqrt_val($a);

Returns the square root of $a. Croaks if $a is negative.

cbrt_val

my $result = cbrt_val($a);

Returns the cube root of $a.

nth_root

my $result = nth_root($a, $n);

Returns the $nth root of $a. Croaks if $n is zero or if taking an even root of a negative number.

log_natural

my $result = log_natural($a);

Returns the natural logarithm (base e) of $a. Croaks if $a is not positive.

log10_val

my $result = log10_val($a);

Returns the base-10 logarithm of $a. Croaks if $a is not positive.

log_base

my $result = log_base($a, $base);

Returns the logarithm of $a with the specified $base. Croaks if arguments are invalid.

exp_val

my $result = exp_val($a);

Returns e raised to the power of $a.

factorial

my $result = factorial($n);

Returns the factorial of $n (i.e., n!). Croaks if $n is negative or greater than 170.

ipow

my $result = ipow($base, $exp);

Returns $base raised to the integer power $exp. This is faster than power() for integer exponents.

safe_sqrt

my $result = safe_sqrt($a);

Returns the square root of $a, or 0 if $a is negative (instead of croaking).

safe_log

my $result = safe_log($a);

Returns the natural logarithm of $a, or 0 if $a is not positive (instead of croaking).

combination

my $result = combination($n, $r);

Returns the number of combinations (binomial coefficient) C(n,r).

permutation

my $result = permutation($n, $r);

Returns the number of permutations P(n,r).

SEE ALSO

Acme::ExtUtils::XSOne::Test::Calculator, Acme::ExtUtils::XSOne::Test::Calculator::Basic, Acme::ExtUtils::XSOne::Test::Calculator::Trig, Acme::ExtUtils::XSOne::Test::Calculator::Memory