Skip to main content

Module atan

Module atan 

Source
Expand description

Arc tangent of f32 for no_std, without libm.

§Méthode

Soit a = |x|. On réduit l’argument à |t| <= tan(π/8) :

  • a > tan(3π/8) : atan(a) = π/2 + atan(-1/a)
  • a > tan(π/8) : atan(a) = π/4 + atan((a-1)/(a+1))
  • sinon : atan(a) = atan(a)

puis atan(t) ≈ t + t·z·Q(z), avec z = t² et Q un polynôme minimax de degré 3 en z (coefficients de l’atanf de la bibliothèque Cephes, S. L. Moshier). Le signe de x est réappliqué sur le résultat.

La forme t + t·z·Q(z) conserve la précision relative près de 0 (jusqu’aux subnormaux).

§Comportement

EntréeSortie
±0.0±0.0 (signe conservé)
±∞±π/2
NaNNaN

Résultat dans [-π/2, π/2].

Functions§

atan
Arc tangente de x, en radians, dans [-π/2, π/2].
atan_norm
atan(x) normalisé dans [-1, 1] (c’est-à-dire atan(x) · 2/π).