Average Error: 31.1 → 0.4
Time: 1.6m
Precision: 64
Internal Precision: 2368
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.03081154504515716:\\ \;\;\;\;\frac{\frac{1 - \cos x}{x}}{x}\\ \mathbf{if}\;x \le 0.03125966913209076:\\ \;\;\;\;\left(\frac{1}{2} + \frac{1}{720} \cdot {x}^{4}\right) - \frac{1}{24} \cdot {x}^{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{x \cdot x}{1 - \cos x}}\\ \end{array}\]

Error

Bits error versus x

Derivation

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

    1. Initial program 1.0

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Using strategy rm
    3. Applied associate-/r*0.5

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

    if -0.03081154504515716 < x < 0.03125966913209076

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

    if 0.03125966913209076 < x

    1. Initial program 1.1

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

Runtime

Time bar (total: 1.6m)Debug logProfile

herbie shell --seed '#(1072840222 1305617769 1692503039 1353360431 4178980589 1488672652)' 
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  (/ (- 1 (cos x)) (* x x)))