Average Error: 31.7 → 0.4
Time: 32.5s
Precision: 64
Internal Precision: 2368
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.028431976646957072:\\ \;\;\;\;\frac{\sqrt{1 - \cos x}}{x} \cdot \frac{\sqrt{1 - \cos x}}{x}\\ \mathbf{elif}\;x \le 0.032105177177255154:\\ \;\;\;\;(\frac{1}{720} \cdot \left({x}^{4}\right) + \frac{1}{2})_* - \left(x \cdot x\right) \cdot \frac{1}{24}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - \cos x}{x \cdot x}\\ \end{array}\]

Error

Bits error versus x

Derivation

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

    1. Initial program 1.1

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt1.2

      \[\leadsto \frac{\color{blue}{\sqrt{1 - \cos x} \cdot \sqrt{1 - \cos x}}}{x \cdot x}\]
    4. Applied times-frac0.6

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

    if -0.028431976646957072 < x < 0.032105177177255154

    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. 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 0.032105177177255154 < x

    1. Initial program 1.0

      \[\frac{1 - \cos x}{x \cdot x}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.028431976646957072:\\ \;\;\;\;\frac{\sqrt{1 - \cos x}}{x} \cdot \frac{\sqrt{1 - \cos x}}{x}\\ \mathbf{elif}\;x \le 0.032105177177255154:\\ \;\;\;\;(\frac{1}{720} \cdot \left({x}^{4}\right) + \frac{1}{2})_* - \left(x \cdot x\right) \cdot \frac{1}{24}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - \cos x}{x \cdot x}\\ \end{array}\]

Runtime

Time bar (total: 32.5s)Debug logProfile

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