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

Error

Bits error versus x

Derivation

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

    1. Initial program 1.2

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

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

    if -0.03675916085591286 < x < 0.0019551307389888218

    1. Initial program 61.3

      \[\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}}\]

    if 0.0019551307389888218 < 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}}\]
  3. Recombined 3 regimes into one program.

Runtime

Time bar (total: 1.1m)Debug log

herbie shell --seed '#(1743936871 1855164119 3668777427 1254258049 132811564 1366975197)' 
(FPCore (x)
  :name "NMSE problem 3.4.1"
  :pre (!= x 0)
  (/ (- 1 (cos x)) (* x x)))