Average Error: 29.7 → 0.5
Time: 34.9s
Precision: 64
Internal precision: 2432
\[\frac{1 - \cos x}{\sin x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.009369761232765748:\\ \;\;\;\;\log \left(e^{\frac{1 - \cos x}{\sin x}}\right)\\ \mathbf{if}\;x \le 0.06423521200938427:\\ \;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{\frac{1 - \cos x}{\sin x}}\right)\\ \end{array}\]

Error

Bits error versus x

Target

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

Derivation

  1. Split input into 3 regimes.
  2. if x < -0.009369761232765748

    1. Initial program 1.0

      \[\frac{1 - \cos x}{\sin x}\]
    2. Using strategy rm
    3. Applied add-log-exp 1.1

      \[\leadsto \color{blue}{\log \left(e^{\frac{1 - \cos x}{\sin x}}\right)}\]

    if -0.009369761232765748 < x < 0.06423521200938427

    1. Initial program 59.8

      \[\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)}\]

    if 0.06423521200938427 < x

    1. Initial program 0.9

      \[\frac{1 - \cos x}{\sin x}\]
    2. Using strategy rm
    3. Applied add-log-exp 1.0

      \[\leadsto \color{blue}{\log \left(e^{\frac{1 - \cos x}{\sin x}}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Removed slow pow expressions

Runtime

Time bar (total: 34.9s) Debug logProfile

Please include this information when filing a bug report:

herbie shell --seed '#(1067488128 1186562765 67428877 2948030040 4169093828 3206893112)'
(FPCore (x)
  :name "tanhf (example 3.4)"
  :herbie-expected 1

  :target
  (tan (/ x 2))

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