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}\]
Target
| Original | 30.0 |
| Comparison | 0.0 |
| Herbie | 0.5 |
\[ \tan \left(\frac{x}{2}\right) \]
Derivation
- Split input into 2 regimes.
-
if x < -5.5164922447739564e-14 or 3.641240225169713e-18 < x
Initial program 2.8
\[\frac{1 - \cos x}{\sin x}\]
- Using strategy
rm
Applied flip-- 3.3
\[\leadsto \frac{\color{blue}{\frac{{1}^2 - {\left(\cos x\right)}^2}{1 + \cos x}}}{\sin x}\]
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
Initial program 60.4
\[\frac{1 - \cos x}{\sin x}\]
Applied taylor 0.0
\[\leadsto \frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\]
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
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)))