Module: BigMathR::Trig

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

Overview

A module that provide the trigonometric functions. It is used internally.
All module functions are implemented by :sincos.

Synopsis

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

  • Sine: :sin

  • Cosine: :cos

  • Tangent: :tan

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

  • Cosecant: :csc

  • Secant: :sec

  • Cotangent: :cot

The following are GNU extensions:

  • sincos(): :sincos

Reference

Kiso kara hatten made Sankaku kansuu (Japanese) - Michimasa Kobayashi (Beret Shuppan)

Class Method Summary collapse

Class Method Details

.cos(x, prec) ⇒ BigDecimal

Computes cosine of x.
x gives in radian.

Examples:

BigMathR::Trig.cos(1, 20)
#=> 0.5403023058681397174e0

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



78
79
80
81
82
# File 'ext/bigdecimal/math_r/trig.c', line 78

static VALUE
__impl_trig_cos(VALUE unused_obj, VALUE x, VALUE prec)
{
	return cos_branch(x, prec, cos_ser);
}

.cot(x, prec) ⇒ BigDecimal

Computes cotangent of x.
x gives in radian.

Examples:

BigMathR::Trig.cot(1, 20)
#=> 0.64209261593433070301e0

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



164
165
166
167
168
# File 'ext/bigdecimal/math_r/trig.c', line 164

static VALUE
__impl_trig_cot(VALUE unused_obj, VALUE x, VALUE prec)
{
	return cot_branch(x, prec, cot_ser);
}

.csc(x, prec) ⇒ BigDecimal

Computes cosecant of x.
x gives in radian.

Examples:

BigMathR::Trig.csc(1, 20)
#=> 0.11883951057781212163e1

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



121
122
123
124
125
# File 'ext/bigdecimal/math_r/trig.c', line 121

static VALUE
__impl_trig_csc(VALUE unused_obj, VALUE x, VALUE prec)
{
	return csc_branch(x, prec, csc_ser);
}

.sec(x, prec) ⇒ BigDecimal

Computes secant of x.
x gives in radian.

Examples:

BigMathR::Trig.sec(1, 20)
#=> 0.18508157176809256179e1

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



142
143
144
145
146
# File 'ext/bigdecimal/math_r/trig.c', line 142

static VALUE
__impl_trig_sec(VALUE unused_obj, VALUE x, VALUE prec)
{
	return sec_branch(x, prec, sec_ser);
}

.sin(x, prec) ⇒ BigDecimal

Computes sine of x.
x gives in radian.

Examples:

BigMathR::Trig.sin(1, 20)
#=> 0.84147098480789650665e0

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



56
57
58
59
60
# File 'ext/bigdecimal/math_r/trig.c', line 56

static VALUE
__impl_trig_sin(VALUE unused_obj, VALUE x, VALUE prec)
{
	return sin_branch(x, prec, sin_ser);
}

.tan(x, prec) ⇒ BigDecimal

Computes tangent of x.
x gives in radian.

Examples:

BigMathR::Trig.tan(1, 20)
#=> 0.15574077246549022305e1

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



100
101
102
103
104
# File 'ext/bigdecimal/math_r/trig.c', line 100

static VALUE
__impl_trig_tan(VALUE unused_obj, VALUE x, VALUE prec)
{
	return tan_branch(x, prec, tan_ser);
}