Average Error: 31.0 → 0.3
Time: 29.9s
Precision: 64
Internal Precision: 2368
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.030162655545638257:\\ \;\;\;\;\frac{1 - \cos x}{x} \cdot \frac{1}{x}\\ \mathbf{elif}\;x \le 2.58027704398774 \cdot 10^{-06}:\\ \;\;\;\;(\frac{1}{720} \cdot \left({x}^{4}\right) + \frac{1}{2})_* - \left(x \cdot x\right) \cdot \frac{1}{24}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin x}{x \cdot x} \cdot \tan \left(\frac{x}{2}\right)\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 3 regimes
  2. if x < -0.030162655545638257

    1. Initial program 1.0

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity1.0

      \[\leadsto \frac{\color{blue}{1 \cdot \left(1 - \cos x\right)}}{x \cdot x}\]
    4. Applied times-frac0.5

      \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{1 - \cos x}{x}}\]

    if -0.030162655545638257 < x < 2.58027704398774e-06

    1. Initial program 61.7

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. 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}}\]
    3. Simplified0.0

      \[\leadsto \color{blue}{(\frac{1}{720} \cdot \left({x}^{4}\right) + \frac{1}{2})_* - \left(x \cdot x\right) \cdot \frac{1}{24}}\]

    if 2.58027704398774e-06 < x

    1. Initial program 1.2

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Using strategy rm
    3. Applied flip--1.4

      \[\leadsto \frac{\color{blue}{\frac{1 \cdot 1 - \cos x \cdot \cos x}{1 + \cos x}}}{x \cdot x}\]
    4. Applied associate-/l/1.5

      \[\leadsto \color{blue}{\frac{1 \cdot 1 - \cos x \cdot \cos x}{\left(x \cdot x\right) \cdot \left(1 + \cos x\right)}}\]
    5. Simplified1.0

      \[\leadsto \frac{\color{blue}{\sin x \cdot \sin x}}{\left(x \cdot x\right) \cdot \left(1 + \cos x\right)}\]
    6. Using strategy rm
    7. Applied times-frac1.0

      \[\leadsto \color{blue}{\frac{\sin x}{x \cdot x} \cdot \frac{\sin x}{1 + \cos x}}\]
    8. Simplified0.7

      \[\leadsto \frac{\sin x}{x \cdot x} \cdot \color{blue}{\tan \left(\frac{x}{2}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.030162655545638257:\\ \;\;\;\;\frac{1 - \cos x}{x} \cdot \frac{1}{x}\\ \mathbf{elif}\;x \le 2.58027704398774 \cdot 10^{-06}:\\ \;\;\;\;(\frac{1}{720} \cdot \left({x}^{4}\right) + \frac{1}{2})_* - \left(x \cdot x\right) \cdot \frac{1}{24}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin x}{x \cdot x} \cdot \tan \left(\frac{x}{2}\right)\\ \end{array}\]

Runtime

Time bar (total: 29.9s)Debug logProfile

herbie shell --seed 2018221 +o rules:numerics
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  (/ (- 1 (cos x)) (* x x)))