Average Error: 30.2 → 0.5
Time: 48.4s
Precision: 64
Internal precision: 2432
\[\frac{1 - \cos x}{x \cdot x}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;x \le -3.859884253300168 \cdot 10^{-07}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{1 - \cos x}{x}\\
\mathbf{if}\;x \le 0.1441617602023804:\\
\;\;\;\;\left(\frac{1}{720} \cdot {x}^{4} + \frac{1}{2}\right) - \frac{1}{24} \cdot {x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin x \cdot \sin x}{\frac{x \cdot x}{\frac{1}{1 + \cos x}}}\\
\end{array}\]
Derivation
- Split input into 3 regimes.
-
if x < -3.859884253300168e-07
Initial program 1.5
\[\frac{1 - \cos x}{x \cdot x}\]
- Using strategy
rm
Applied *-un-lft-identity 1.5
\[\leadsto \frac{\color{blue}{1 \cdot \left(1 - \cos x\right)}}{x \cdot x}\]
Applied times-frac 0.9
\[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{1 - \cos x}{x}}\]
if -3.859884253300168e-07 < x < 0.1441617602023804
Initial program 61.6
\[\frac{1 - \cos x}{x \cdot x}\]
Taylor expanded around 0 0.0
\[\leadsto \color{blue}{\left(\frac{1}{720} \cdot {x}^{4} + \frac{1}{2}\right) - \frac{1}{24} \cdot {x}^{2}}\]
if 0.1441617602023804 < x
Initial program 1.0
\[\frac{1 - \cos x}{x \cdot x}\]
- Using strategy
rm
Applied flip-- 1.2
\[\leadsto \frac{\color{blue}{\frac{1 \cdot 1 - \cos x \cdot \cos x}{1 + \cos x}}}{x \cdot x}\]
Applied simplify 1.1
\[\leadsto \frac{\frac{\color{blue}{\sin x \cdot \sin x}}{1 + \cos x}}{x \cdot x}\]
- Using strategy
rm
Applied div-inv 1.1
\[\leadsto \frac{\color{blue}{\left(\sin x \cdot \sin x\right) \cdot \frac{1}{1 + \cos x}}}{x \cdot x}\]
Applied associate-/l* 1.1
\[\leadsto \color{blue}{\frac{\sin x \cdot \sin x}{\frac{x \cdot x}{\frac{1}{1 + \cos x}}}}\]
- Recombined 3 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(2329929097 3210370195 3111198779 2406363002 3511342718 2136436390)'
(FPCore (x)
:name "cos2 (problem 3.4.1)"
(/ (- 1 (cos x)) (* x x)))