[][src]Trait maths_traits::analysis::real::Trig

pub trait Trig: UnitalRing + Divisibility {
    fn sin(self) -> Self;
fn cos(self) -> Self;
fn tan(self) -> Self;
fn sinh(self) -> Self;
fn cosh(self) -> Self;
fn tanh(self) -> Self;
fn try_asin(self) -> Option<Self>;
fn try_acos(self) -> Option<Self>;
fn atan(self) -> Self;
fn atan2(y: Self, x: Self) -> Self;
fn try_asinh(self) -> Option<Self>;
fn try_acosh(self) -> Option<Self>;
fn try_atanh(self) -> Option<Self>;
fn pi() -> Self; fn sin_cos(self) -> (Self, Self) { ... }
fn asin(self) -> Self { ... }
fn acos(self) -> Self { ... }
fn asinh(self) -> Self { ... }
fn acosh(self) -> Self { ... }
fn atanh(self) -> Self { ... }
fn frac_2_pi() -> Self { ... }
fn frac_pi_2() -> Self { ... }
fn frac_pi_3() -> Self { ... }
fn frac_pi_4() -> Self { ... }
fn frac_pi_6() -> Self { ... }
fn frac_pi_8() -> Self { ... }
fn pythag_const() -> Self { ... }
fn pythag_const_inv() -> Self { ... }
fn to_degrees(self) -> Self { ... }
fn to_radians(self) -> Self { ... } }

Functions and constants for evaluative trigonometric values

For the most part, these methods are meant for struct representing real numbers, and so, for those, the included functions have their normal meaning. However, in order to include the generalizations (such as the complex trig functions), the precise definitions are defined in a more abstract way.

Specifically, all of the included methods should satisfy the relevant differential equation definition of its function. Specifically:

  • Sine and Cosine should satisfy
    • d/dx cos(x) = -sin(x)
    • d/dx sin(x) = cos(x)
    • cos(0) = 1
    • sin(0) = 0
  • Tangent should satisfy
    • d/dx tan(x) = 1 + tan²(x)
    • tan(0) = 0
  • Hyperbolic Sine and Hyperbolic Cosine should satisfy
    • d/dx cosh(x) = sinh(x)
    • d/dx sinh(x) = cosh(x)
    • cosh(0) = 1
    • sinh(0) = 0
  • Hyperbolic Tangent should satisfy
    • d/dx tanh(x) = 1 - tanh²(x)
    • tanh(0) = 0

Of course, for Real and Complex numbers, the standard infinite series definitions also apply and are most likely the method of computation.

Required methods

fn sin(self) -> Self

Finds the Sine of the given value

For more general inputs, this is defined as the solution to:

  • f"(x) = -f(x)
  • f(0) = 0
  • f'(0) = 1

fn cos(self) -> Self

Finds the Cosine of the given value

For more general inputs, this is defined as the solution to:

  • f"(x) = -f(x)
  • f(0) = 1
  • f'(0) = 0

fn tan(self) -> Self

Finds the Tangent of the given value

For more general inputs, this is defined as the solution to:

  • f'(x) = 1 + f(x)²
  • f(0) = 0

fn sinh(self) -> Self

Finds the Hyperbolic Sine of the given value

For more general inputs, this is defined as the solution to:

  • f"(x) = f(x)
  • f(0) = 0
  • f'(0) = 1

fn cosh(self) -> Self

Finds the Hyperbolic Cosine of the given value

For more general inputs, this is defined as the solution to:

  • f"(x) = f(x)
  • f(0) = 1
  • f'(0) = 0

fn tanh(self) -> Self

Finds the Hyperbolic Tangent of the given value

For more general inputs, this is defined as the solution to:

  • f'(x) = 1 - f(x)²
  • f(0) = 0

fn try_asin(self) -> Option<Self>

A continuous inverse function of Sine such that asin(1) = π/2 and asin(-1) = -π/2

Returns a None value if and only if the inverse doesn't exist for the given input

fn try_acos(self) -> Option<Self>

A continuous inverse function of Cosine such that acos(1) = 0 and asin(-1) = π

Returns a None value if and only if the inverse doesn't exist for the given input

fn atan(self) -> Self

A continuous inverse function of Tangent such that atan(0) = 0 and atan(1) = π/4

fn atan2(y: Self, x: Self) -> Self

A continuous function of two variables where tan(atan2(y,x)) = y/x for y!=0 and atan2(0,1) = 0

This is particularly useful for real numbers, where this gives the angle a vector (x,y) makes with the x-axis, without the singularities and ambiguity of computing atan(y/x)

fn try_asinh(self) -> Option<Self>

A continuous inverse function of Hyperbolic Sine such that asinh(0)=0

Returns a None value if and only if the inverse doesn't exist for the given input

fn try_acosh(self) -> Option<Self>

A continuous inverse function of Hyperbolic Cosine such that acosh(0)=1

Returns a None value if and only if the inverse doesn't exist for the given input

fn try_atanh(self) -> Option<Self>

A continuous inverse function of Hyperbolic Tangent such that atanh(0)=0

Returns a None value if and only if the inverse doesn't exist for the given input

fn pi() -> Self

The classic cicle constant

For real-algebras, this should be exactly what you expect: the ratio of a circle's cicumferance to its diameter. However, in keeping with the generalized trig function definitions, this should give the value of acos(-1) and be a zero of Sine and Tangent regardless of if it is the circle constant for the euclidean metric

Loading content...

Provided methods

fn sin_cos(self) -> (Self, Self)

Finds both the Sine and Cosine as a tuple

This is supposed to mirror f32::sin_cos() and f64::sin_cos()

fn asin(self) -> Self

A continuous inverse function of Sine such that asin(1) = π/2 and asin(-1) = -π/2

If the inverse does not exist for the given input, then the implementation can decide between a panic! or returning some form of error value (like NaN). In general though, there is no guarrantee which of these will occur, so it is suggested to use Trig::try_asin in such cases.

fn acos(self) -> Self

A continuous inverse function of Cosine such that acos(1) = 0 and asin(-1) = π

If the inverse does not exist for the given input, then the implementation can decide between a panic! or returning some form of error value (like NaN). In general though, there is no guarrantee which of these will occur, so it is suggested to use Trig::try_acos in such cases.

fn asinh(self) -> Self

A continuous inverse function of Hyperbolic Sine such that asinh(0)=0

If the inverse does not exist for the given input, then the implementation can decide between a panic! or returning some form of error value (like NaN). In general though, there is no guarrantee which of these will occur, so it is suggested to use Trig::try_asinh in such cases.

fn acosh(self) -> Self

A continuous inverse function of Hyperbolic Cosine such that acosh(0)=1

If the inverse does not exist for the given input, then the implementation can decide between a panic! or returning some form of error value (like NaN). In general though, there is no guarrantee which of these will occur, so it is suggested to use Trig::try_acosh in such cases.

fn atanh(self) -> Self

A continuous inverse function of Hyperbolic Tangent such that atanh(0)=0

If the inverse does not exist for the given input, then the implementation can decide between a panic! or returning some form of error value (like NaN). In general though, there is no guarrantee which of these will occur, so it is suggested to use Trig::try_atanh in such cases.

fn frac_2_pi() -> Self

2/π. Mirrors FRAC_2_PI

fn frac_pi_2() -> Self

π/2. Mirrors FRAC_PI_2

fn frac_pi_3() -> Self

π/3. Mirrors FRAC_PI_3

fn frac_pi_4() -> Self

π/4. Mirrors FRAC_PI_4

fn frac_pi_6() -> Self

π/6. Mirrors FRAC_PI_6

fn frac_pi_8() -> Self

π/8. Mirrors FRAC_PI_8

fn pythag_const() -> Self

The length of the hypotenuse of a unit right-triangle. Mirrors SQRT_2

fn pythag_const_inv() -> Self

The sine of π/4. Mirrors FRAC_1_SQRT_2

fn to_degrees(self) -> Self

fn to_radians(self) -> Self

Loading content...

Implementations on Foreign Types

impl Trig for f32[src]

impl Trig for f64[src]

Loading content...

Implementors

Loading content...