Average Error: 31.1 → 0.3
Time: 15.0s
Precision: 64
Internal precision: 2432
\[\frac{1 - \cos x}{{x}^2}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;x \le -4.010384934750878 \cdot 10^{-06}:\\
\;\;\;\;{\left(\frac{\sqrt{\frac{{\left(\sin x\right)}^2}{1 + \cos x}}}{x}\right)}^2\\
\mathbf{if}\;x \le 0.0309538262003119:\\
\;\;\;\;\left(\frac{1}{2} + \frac{1}{720} \cdot {x}^{4}\right) - \frac{1}{24} \cdot {x}^2\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{\sqrt{\frac{{\left(\sin x\right)}^2}{1 + \cos x}}}{x}\right)}^2\\
\end{array}\]
Derivation
- Split input into 2 regimes.
-
if x < -4.010384934750878e-06 or 0.0309538262003119 < x
Initial program 1.3
\[\frac{1 - \cos x}{{x}^2}\]
- Using strategy
rm
Applied flip-- 1.5
\[\leadsto \frac{\color{blue}{\frac{{1}^2 - {\left(\cos x\right)}^2}{1 + \cos x}}}{{x}^2}\]
Applied simplify 1.2
\[\leadsto \frac{\frac{\color{blue}{\sin x \cdot \sin x}}{1 + \cos x}}{{x}^2}\]
- Using strategy
rm
Applied add-sqr-sqrt 1.3
\[\leadsto \frac{\color{blue}{{\left(\sqrt{\frac{\sin x \cdot \sin x}{1 + \cos x}}\right)}^2}}{{x}^2}\]
Applied square-undiv 0.6
\[\leadsto \color{blue}{{\left(\frac{\sqrt{\frac{\sin x \cdot \sin x}{1 + \cos x}}}{x}\right)}^2}\]
Applied simplify 0.6
\[\leadsto {\color{blue}{\left(\frac{\sqrt{\frac{{\left(\sin x\right)}^2}{1 + \cos x}}}{x}\right)}}^2\]
if -4.010384934750878e-06 < x < 0.0309538262003119
Initial program 61.5
\[\frac{1 - \cos x}{{x}^2}\]
Applied taylor 0.0
\[\leadsto \left(\frac{1}{2} + \frac{1}{720} \cdot {x}^{4}\right) - \frac{1}{24} \cdot {x}^2\]
Taylor expanded around 0 0.0
\[\leadsto \color{blue}{\left(\frac{1}{2} + \frac{1}{720} \cdot {x}^{4}\right) - \frac{1}{24} \cdot {x}^2}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(1066785882 2324371342 4059510649 1466361199 2701357084 1216585281)'
(FPCore (x)
:name "cos2 (problem 3.4.1)"
(/ (- 1 (cos x)) (sqr x)))