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

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.03021091695231464 or 0.03040127665186386 < x

    1. Initial program 1.1

      \[\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.03021091695231464 < x < 0.03040127665186386

    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.8m)Debug logProfile

herbie shell --seed '#(1070833653 108281690 3330367898 3632331308 3494323072 43156186)' +o rules:numerics
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  (/ (- 1 (cos x)) (* x x)))