Module: BigMathR::Hyperb

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

Overview

A module that provides a hyperbolic functions. It is used internally.
It handle the real number solutions. The algorithm is implemented according to the references, when |x| < 3 computes to series expansion, otherwise computes by exponent identity.

Synopsis

The function names defined are the same as those in the C/C++ standard.

  • Hyperbolic Sine: :sinh

  • Hyperbolic Cosine: :cosh

  • Hyperbolic Tangent: :tanh

Follow, those reciprocals of not defined in C/C++ standard.

  • Hyperbolic Cosecant: :csch

  • Hyperbolic Secant: :sech

  • Hyperbolic Cotangent: :coth

Reference

C-gengo ni yoru hyoujun alkgorithm jiten (Japanese) - Hasruhiko Okumura (Gijutsu hyouron-sha)

Class Method Summary collapse

Class Method Details

.cosh(x, prec) ⇒ BigDecimal

Computes hyperbolic cosine of x.

Examples:

BigMathR::Hyperb.cosh(1, 20) # Series expansion
#=> 0.15430806348152437785e1
BigMathR::Hyperb.cosh(4, 20) # Formula
#=> 0.27308232836016486629e2

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



50
51
52
53
54
# File 'ext/bigdecimal/math_r/hyperb.c', line 50

static VALUE
__impl_hyperb_cosh(VALUE unused_obj, VALUE x, VALUE prec)
{
  return cosh_branch(x, prec, cosh_formula);
}

.coth(x, prec) ⇒ BigDecimal

Computes hyperbolic cotangent of x.

Examples:

BigMathR::Hyperb.coth(1, 20) # Series expansion
#=> 0.13130352854993313036e1
BigMathR::Hyperb.coth(4, 20) # Formula
#=> 0.10006711504016824899e1

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



134
135
136
137
138
# File 'ext/bigdecimal/math_r/hyperb.c', line 134

static VALUE
__impl_hyperb_coth(VALUE unused_obj, VALUE x, VALUE prec)
{
  return coth_branch(x, prec, coth_formula);
}

.csch(x, prec) ⇒ BigDecimal

Computes hyperbolic cosecant of x.

Examples:

BigMathR::Hyperb.csch(1, 20) # Series expansion
#=> 0.85091812823932154512e0
BigMathR::Hyperb.csch(4, 20) # Formula
#=> 0.36643570325865605966e-1

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



92
93
94
95
96
# File 'ext/bigdecimal/math_r/hyperb.c', line 92

static VALUE
__impl_hyperb_csch(VALUE unused_obj, VALUE x, VALUE prec)
{
  return csch_branch(x, prec, csch_formula);
}

.sech(x, prec) ⇒ BigDecimal

Computes hyperbolic secant of x.

Examples:

BigMathR::Hyperb.sech(1, 20) # Series expansion
#=> 0.64805427366388539957e0
BigMathR::Hyperb.sech(4, 20) # Formula
#=> 0.36618993473686532773e-1

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



113
114
115
116
117
# File 'ext/bigdecimal/math_r/hyperb.c', line 113

static VALUE
__impl_hyperb_sech(VALUE unused_obj, VALUE x, VALUE prec)
{
  return sech_branch(x, prec, sech_formula);
}

.tanh(x, prec) ⇒ BigDecimal

Computes hyperbolic tangent of x.

Examples:

BigMathR::Hyperb.tanh(1, 20) # Series expansion
#=> 0.76159415595576488812e0
BigMathR::Hyperb.tanh(4, 20) # Formula
#=> 0.99932929973906704379e0

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



71
72
73
74
75
# File 'ext/bigdecimal/math_r/hyperb.c', line 71

static VALUE
__impl_hyperb_tanh(VALUE unused_obj, VALUE x, VALUE prec)
{
  return tanh_branch(x, prec, tanh_formula);
}