Average Error: 31.1 → 0.3
Time: 1.5m
Precision: 64
Internal Precision: 2432
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.013114498929173083:\\ \;\;\;\;\frac{\sin x \cdot \sin x}{x} \cdot \frac{\frac{1}{1 + \cos x}}{x}\\ \mathbf{if}\;x \le 0.010961042371102528:\\ \;\;\;\;\left(\frac{1}{2} + \frac{1}{720} \cdot {x}^{4}\right) - \frac{1}{24} \cdot {x}^{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin x \cdot \sin x}{x} \cdot \frac{\frac{1}{1 + \cos x}}{x}\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.013114498929173083 or 0.010961042371102528 < x

    1. Initial program 1.1

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

      \[\leadsto \frac{\color{blue}{\frac{1 \cdot 1 - \cos x \cdot \cos x}{1 + \cos x}}}{x \cdot x}\]
    4. Applied simplify1.1

      \[\leadsto \frac{\frac{\color{blue}{\sin x \cdot \sin x}}{1 + \cos x}}{x \cdot x}\]
    5. Using strategy rm
    6. Applied div-inv1.1

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

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

    if -0.013114498929173083 < x < 0.010961042371102528

    1. Initial program 61.4

      \[\frac{1 - \cos x}{x \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}}\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 1.5m)Debug logProfile

herbie shell --seed '#(1064269945 2896236262 301053905 1701069080 1701464310 1614783279)' 
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  (/ (- 1 (cos x)) (* x x)))