Average Error: 30.0 → 0.5
Time: 16.8s
Precision: 64
Internal precision: 2432
\[\frac{1 - \cos x}{\sin x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -5.5164922447739564 \cdot 10^{-14}:\\ \;\;\;\;\frac{\frac{\sin x \cdot \sin x}{1 + \cos x}}{\sin x}\\ \mathbf{if}\;x \le 3.641240225169713 \cdot 10^{-18}:\\ \;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sin x \cdot \sin x}{1 + \cos x}}{\sin x}\\ \end{array}\]

Error

Bits error versus x

Target

Original30.0
Comparison0.0
Herbie0.5
\[ \tan \left(\frac{x}{2}\right) \]

Derivation

  1. Split input into 2 regimes.
  2. if x < -5.5164922447739564e-14 or 3.641240225169713e-18 < x

    1. Initial program 2.8

      \[\frac{1 - \cos x}{\sin x}\]
    2. Using strategy rm
    3. Applied flip-- 3.3

      \[\leadsto \frac{\color{blue}{\frac{{1}^2 - {\left(\cos x\right)}^2}{1 + \cos x}}}{\sin x}\]
    4. Applied simplify 1.0

      \[\leadsto \frac{\frac{\color{blue}{\sin x \cdot \sin x}}{1 + \cos x}}{\sin x}\]

    if -5.5164922447739564e-14 < x < 3.641240225169713e-18

    1. Initial program 60.4

      \[\frac{1 - \cos x}{\sin x}\]
    2. Applied taylor 0.0

      \[\leadsto \frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\]
    3. Taylor expanded around 0 0.0

      \[\leadsto \color{blue}{\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)}\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions

Runtime

Time bar (total: 16.8s) Debug logProfile

Please include this information when filing a bug report:

herbie shell --seed '#(1064651971 495577305 2200811460 13024471 864198081 231948279)'
(FPCore (x)
  :name "tanhf (example 3.4)"
  :herbie-expected 1

  :target
  (tan (/ x 2))

  (/ (- 1 (cos x)) (sin x)))