Average Error: 31.0 → 0.3
Time: 22.4s
Precision: 64
Internal precision: 128
\[\frac{1 - \cos x}{{x}^2}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;x \le -5.458497096453193 \cdot 10^{-06}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{1 - \cos x}{x}\\
\mathbf{if}\;x \le 85.36504497937187:\\
\;\;\;\;\left(\frac{1}{2} + \frac{1}{720} \cdot {x}^{4}\right) - \frac{1}{24} \cdot {x}^2\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{1 - \cos x}{x}\\
\end{array}\]
Derivation
- Split input into 2 regimes.
-
if x < -5.458497096453193e-06 or 85.36504497937187 < x
Initial program 1.2
\[\frac{1 - \cos x}{{x}^2}\]
- Using strategy
rm
Applied square-mult 1.2
\[\leadsto \frac{1 - \cos x}{\color{blue}{x \cdot x}}\]
Applied *-un-lft-identity 1.2
\[\leadsto \frac{\color{blue}{1 \cdot \left(1 - \cos x\right)}}{x \cdot x}\]
Applied times-frac 0.6
\[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{1 - \cos x}{x}}\]
if -5.458497096453193e-06 < x < 85.36504497937187
Initial program 61.4
\[\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 --seed '#(2450642636 2863344379 4098708838 1734408276 15201110 2842944231)'
(FPCore (x)
:name "cos2 (problem 3.4.1)"
(/ (- 1 (cos x)) (sqr x)))