hyperbolic
nimony/lib/std/math/hyperbolic.nim
Native (libc-free) implementations of expm1, sinh, cosh, tanh, arcsinh, arccosh and arctanh. The hyperbolic formulas and range handling follow Rust compiler-builtins/libm's corresponding f32/f64 routines; expm1 is adapted from FreeBSD/SunPro fdlibm s_expm1.c. Rust sources: library/compiler-builtins/libm/src/math/{expm1,expm1f,sinh,sinhf,cosh,coshf,tanh,tanhf,asinh,asinhf,acosh,acoshf,atanh,atanhf,k_expo2,k_expo2f}.rs. Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. Copyright (c) 2018 Jorge Aparicio (Rust compiler-builtins/libm code). Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved. Selected instead of math/cmath by std/math when nimNativeIo is defined.
func expm1(x: float64): float64Exponential, base e, of x-1 (f64)
Calculates the exponential of
xand subtract 1, that is, e raised to the powerxminus 1 (where e is the base of the natural system of logarithms, approximately 2.71828). The result is accurate even for small values ofx, where usingexp(x)-1would lose many significant digits.func expm1(x: float32): float32Exponential, base e, of x-1 (f32)
Calculates the exponential of
xand subtract 1, that is, e raised to the powerxminus 1 (where e is the base of the natural system of logarithms, approximately 2.71828). The result is accurate even for small values ofx, where usingexp(x)-1would lose many significant digits.func k_expo2(x: float64): float64Compute exp(x)/2 for x >= log(DBL_MAX), slightly better than 0.5exp(x/2)exp(x/2)
func k_expo2f(x: float32): float32Compute expf(x)/2 for x >= log(FLT_MAX), slightly better than 0.5fexpf(x/2)expf(x/2)
func sinh(x: float32): float32The hyperbolic sine of
x(f32).func sinh(x: float64): float64The hyperbolic sine of
x(f64).func cosh(x: float32): float32Hyperbolic cosine (f32)
Computes the hyperbolic cosine of the argument x. Is defined as
(exp(x) + exp(-x))/2Angles are specified in radians.func cosh(x: float64): float64Hyperbolic cosine (f64)
Computes the hyperbolic cosine of the argument x. Is defined as
(exp(x) + exp(-x))/2Angles are specified in radians.func tanh(x: float32): float32The hyperbolic tangent of
x(f32).xis specified in radians.func tanh(x: float64): float64The hyperbolic tangent of
x(f64).xis specified in radians.func arcsinh(x: float32): float32Inverse hyperbolic sine (f32)
Calculates the inverse hyperbolic sine of
x. Is defined assgn(x)*log(|x|+sqrt(x*x+1)).func arcsinh(x: float64): float64Inverse hyperbolic sine (f64)
Calculates the inverse hyperbolic sine of
x. Is defined assgn(x)*log(|x|+sqrt(x*x+1)).func arccosh(x: float32): float32Inverse hyperbolic cosine (f32)
Calculates the inverse hyperbolic cosine of
x. Is defined aslog(x + sqrt(x*x-1)).xmust be a number greater than or equal to 1.func arccosh(x: float64): float64Inverse hyperbolic cosine (f64)
Calculates the inverse hyperbolic cosine of
x. Is defined aslog(x + sqrt(x*x-1)).xmust be a number greater than or equal to 1.func arctanh(x: float32): float32Inverse hyperbolic tangent (f32)
Calculates the inverse hyperbolic tangent of
x. Is defined aslog((1+x)/(1-x))/2 = log1p(2x/(1-x))/2.func arctanh(x: float64): float64Inverse hyperbolic tangent (f64)
Calculates the inverse hyperbolic tangent of
x. Is defined aslog((1+x)/(1-x))/2 = log1p(2x/(1-x))/2.