Average Error: 30.7 → 0.3
Time: 2.0m
Precision: 64
Internal Precision: 2432
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.031177210554438572:\\ \;\;\;\;\frac{1}{x} \cdot \frac{1 - \cos x}{x}\\ \mathbf{if}\;x \le 0.03059345154090134:\\ \;\;\;\;(\left({x}^{4}\right) \cdot \frac{1}{720} + \frac{1}{2})_* - x \cdot \left(\frac{1}{24} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x} \cdot \frac{1 - \cos x}{x}\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.031177210554438572 or 0.03059345154090134 < x

    1. Initial program 1.0

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity1.0

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

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

    if -0.031177210554438572 < x < 0.03059345154090134

    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. Applied simplify0.0

      \[\leadsto \color{blue}{(\left({x}^{4}\right) \cdot \frac{1}{720} + \frac{1}{2})_* - x \cdot \left(\frac{1}{24} \cdot x\right)}\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 2.0m)Debug logProfile

herbie shell --seed '#(1070386091 2509006183 1430610344 1025408621 36622005 1425925650)' +o rules:numerics
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  (/ (- 1 (cos x)) (* x x)))