Module: BigMathR::Exp

Defined in:
ext/bigdecimal/math_r/exp.c,
ext/bigdecimal/math_r/math_r.c

Overview

A module that treats the exponential functions. It is used internally.
This formula was discovered by the author shortly afterwards. It will be proven in time.

Synopsis:

The function names defined are the same as those in the C/C++ standard.
Exponential function: exp()
Base-2 (binary) exponent: exp2()
expm1 function: expm1()

Class Method Summary collapse

Class Method Details

.cexpm1_identity(z, prec) ⇒ Complex

Computes the subtracted 1 from z of the exponential function.

Examples:

BigMathR::Exp.cexpm1_identity(1+1i, 20)
# => (0.46869393991588515714e0+0.22873552871788423912e1i)

Parameters:

  • z (Numeric)

    Numerical argument

  • prec (Integer)

    Arbitrary precision

Returns:

Raises:

  • (ArgumentError)

    Occurs when prec is not a positive integer.

  • (TypeError)

    Occurs when z is not a numeric class.

Since:

  • 0.2.2



84
85
86
87
88
# File 'ext/bigdecimal/math_r/exp.c', line 84

static VALUE
__impl_cexpm1_identity(VALUE unused_obj, VALUE z, VALUE prec)
{
	return cexpm1_branch(z, prec, cexpm1_identity);
}

.exp2_edf(x, prec) ⇒ BigDecimal

Computes binary exponent of x.

Examples:

BigMathR::Exp.exp2_edf(1/2r, 20)
#=> 0.14142135623730950488e1

Parameters:

  • x (Numeric)

    Numerical argument

  • prec (Integer)

    Arbitrary precision

Returns:

  • (BigDecimal)

    Real solution

Raises:

  • (ArgumentError)

    Occurs when prec is not a positive integer.

  • (TypeError)

    Occurs when x is not a numeric class.

Since:

  • 0.1.0



45
46
47
48
49
# File 'ext/bigdecimal/math_r/exp.c', line 45

static VALUE
__impl_exp2_edf(VALUE unused_obj, VALUE x, VALUE prec)
{
	return exp2_branch(x, prec, exp2_edf);
}

.expm1_identity(x, prec) ⇒ BigDecimal

Computes the subtracted 1 from x of the exponential function.
The calculation is more accurate than exp(x)-1 when the argument is near zero.

Examples:

BigMathR::Exp.expm1_identity(BigDecimal(1), 20)
#=> 0.17182818284590452354e1

Parameters:

  • x (Numeric)

    Numerical argument

  • prec (Integer)

    Arbitrary precision

Returns:

  • (BigDecimal)

    Real solution

Raises:

  • (ArgumentError)

    Occurs when prec is not a positive integer.

  • (TypeError)

    Occurs when x is not a numeric class.

Since:

  • 0.2.2



65
66
67
68
69
# File 'ext/bigdecimal/math_r/exp.c', line 65

static VALUE
__impl_expm1_identity(VALUE unused_obj, VALUE x, VALUE prec)
{
	return expm1_branch(x, prec, expm1_identity);
}