Average Error: 31.1 → 0.9
Time: 1.2m
Precision: 64
Internal Precision: 2368
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;\frac{1 - \cos x}{x \cdot x} \le 1.956654687673076 \cdot 10^{-08}:\\ \;\;\;\;\frac{\left(-\sin x\right) \cdot \tan \left(\frac{x}{2}\right)}{-x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;(\left({x}^{4}\right) \cdot \frac{1}{720} + \frac{1}{2})_* - x \cdot \left(\frac{1}{24} \cdot x\right)\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if (/ (- 1 (cos x)) (* x x)) < 1.956654687673076e-08

    1. Initial program 21.7

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

      \[\leadsto \frac{\color{blue}{\frac{1 \cdot 1 - \cos x \cdot \cos x}{1 + \cos x}}}{x \cdot x}\]
    4. Applied simplify0.8

      \[\leadsto \frac{\frac{\color{blue}{\sin x \cdot \sin x}}{1 + \cos x}}{x \cdot x}\]
    5. Using strategy rm
    6. Applied frac-2neg0.8

      \[\leadsto \color{blue}{\frac{-\frac{\sin x \cdot \sin x}{1 + \cos x}}{-x \cdot x}}\]
    7. Applied simplify0.6

      \[\leadsto \frac{\color{blue}{\left(-\sin x\right) \cdot \tan \left(\frac{x}{2}\right)}}{-x \cdot x}\]

    if 1.956654687673076e-08 < (/ (- 1 (cos x)) (* x x))

    1. Initial program 58.4

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Taylor expanded around 0 1.5

      \[\leadsto \color{blue}{\left(\frac{1}{2} + \frac{1}{720} \cdot {x}^{4}\right) - \frac{1}{24} \cdot {x}^{2}}\]
    3. Applied simplify1.5

      \[\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: 1.2m)Debug logProfile

herbie shell --seed '#(1071246582 2318319007 2683472949 3810440501 3233274817 2724848749)' +o rules:numerics
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  (/ (- 1 (cos x)) (* x x)))