Average Error: 30.0 → 0.5
Time: 2.2m
Precision: 64
Internal Precision: 2432
\[\frac{1 - \cos x}{\sin x}\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \le -0.024894411913591076:\\
\;\;\;\;\frac{e^{\log \left(1 - \cos x\right)}}{\sin x}\\
\mathbf{if}\;x \le 0.023314860336167698:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\log \left(1 - \cos x\right)}}{\sin x}\\
\end{array}\]
Target
| Original | 30.0 |
|---|
| Target | 0.0 |
|---|
| Herbie | 0.5 |
|---|
\[\tan \left(\frac{x}{2}\right)\]
Derivation
- Split input into 2 regimes
if x < -0.024894411913591076 or 0.023314860336167698 < x
Initial program 0.9
\[\frac{1 - \cos x}{\sin x}\]
- Using strategy
rm Applied add-exp-log0.9
\[\leadsto \frac{\color{blue}{e^{\log \left(1 - \cos x\right)}}}{\sin x}\]
if -0.024894411913591076 < x < 0.023314860336167698
Initial program 59.7
\[\frac{1 - \cos x}{\sin x}\]
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)}\]
- Recombined 2 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(1063154770 1824007522 645063331 41291047 494775821 1237684644)'
(FPCore (x)
:name "tanhf (example 3.4)"
:herbie-expected 1
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))