Average Error: 29.5 → 0.5
Time: 1.2m
Precision: 64
Ground Truth: 128
\[\frac{1 - \cos x}{\sin x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -7.829158115972637 \cdot 10^{-05}:\\ \;\;\;\;\frac{\frac{{\left(\sin x\right)}^2}{1 + \cos x}}{\sin x}\\ \mathbf{if}\;x \le 2.576641619206354 \cdot 10^{-19}:\\ \;\;\;\;\frac{1}{2} \cdot x + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{24} \cdot {x}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{\left(\sin x\right)}^2}{1 + \cos x}}{\sin x}\\ \end{array}\]

Error

Bits error versus x

Target

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

Derivation

  1. Split input into 3 regimes.
  2. if x < -7.829158115972637e-05

    1. Initial program 1.0

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

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

      \[\leadsto \frac{\frac{\color{blue}{{\left(\sin x\right)}^2}}{1 + \cos x}}{\sin x}\]

    if -7.829158115972637e-05 < x < 2.576641619206354e-19

    1. Initial program 60.4

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

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

      \[\leadsto \color{blue}{\frac{1}{2} \cdot x + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{24} \cdot {x}^{3}\right)}\]

    if 2.576641619206354e-19 < x

    1. Initial program 3.1

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

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

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

Runtime

Total time: 1.2m Debug log

Please include this information when filing a bug report:

herbie --seed '#(1375390990 3401225523 3162399798 109323623 3488613185 467220258)'
(FPCore (x)
  :name "NMSE example 3.4"
  :herbie-expected 1

  :target
  (tan (/ x 2))

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