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

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.013032351641669214 or 0.00982517273317034 < x

    1. Initial program 1.0

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

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

      \[\leadsto \frac{\frac{\color{blue}{\sin x \cdot \sin x}}{1 + \cos x}}{x \cdot x}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity1.0

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{\sin x \cdot \sin x}{1 + \cos x}}}{x \cdot x}\]
    7. Applied times-frac0.6

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

    if -0.013032351641669214 < x < 0.00982517273317034

    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}{720} \cdot {x}^{4} + \frac{1}{2}\right) - \frac{1}{24} \cdot {x}^{2}}\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions.
  5. Applied simplify0.3

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;x \le -0.013032351641669214:\\ \;\;\;\;\frac{\frac{\sin x}{x}}{\frac{1 + \cos x}{\frac{\sin x}{x}}}\\ \mathbf{if}\;x \le 0.00982517273317034:\\ \;\;\;\;\frac{1}{2} + \left(\frac{1}{720} \cdot {x}^{4} - \left(x \cdot x\right) \cdot \frac{1}{24}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sin x}{x}}{\frac{1 + \cos x}{\frac{\sin x}{x}}}\\ \end{array}}\]

Runtime

Time bar (total: 24.4s)Debug log

herbie shell --seed '#(633950927 2092594946 1442981 2827247922 2812758452 390991499)' 
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  (/ (- 1 (cos x)) (* x x)))