Average Error: 30.4 → 0.4
Time: 24.2s
Precision: 64
Internal Precision: 128
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.009745756652596336:\\ \;\;\;\;\tan \left(\frac{x}{2}\right) \cdot \frac{\sin x}{x \cdot x}\\ \mathbf{elif}\;x \le 0.025343046100655117:\\ \;\;\;\;\frac{1}{(\frac{1}{120} \cdot \left({x}^{4}\right) + \left((\left(x \cdot x\right) \cdot \frac{1}{6} + 2)_*\right))_*}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{1 - \cos x}}{x} \cdot \frac{\sqrt{1 - \cos x}}{x}\\ \end{array}\]

Error

Bits error versus x

Derivation

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

    1. Initial program 1.1

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

      \[\leadsto \frac{\color{blue}{\frac{1 \cdot 1 - \cos x \cdot \cos x}{1 + \cos x}}}{x \cdot x}\]
    4. Applied associate-/l/1.3

      \[\leadsto \color{blue}{\frac{1 \cdot 1 - \cos x \cdot \cos x}{\left(x \cdot x\right) \cdot \left(1 + \cos x\right)}}\]
    5. Simplified1.1

      \[\leadsto \frac{\color{blue}{\sin x \cdot \sin x}}{\left(x \cdot x\right) \cdot \left(1 + \cos x\right)}\]
    6. Using strategy rm
    7. Applied +-commutative1.1

      \[\leadsto \frac{\sin x \cdot \sin x}{\left(x \cdot x\right) \cdot \color{blue}{\left(\cos x + 1\right)}}\]
    8. Using strategy rm
    9. Applied times-frac1.1

      \[\leadsto \color{blue}{\frac{\sin x}{x \cdot x} \cdot \frac{\sin x}{\cos x + 1}}\]
    10. Simplified0.8

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

    if -0.009745756652596336 < x < 0.025343046100655117

    1. Initial program 61.4

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

      \[\leadsto \frac{\color{blue}{\frac{1 \cdot 1 - \cos x \cdot \cos x}{1 + \cos x}}}{x \cdot x}\]
    4. Applied associate-/l/61.4

      \[\leadsto \color{blue}{\frac{1 \cdot 1 - \cos x \cdot \cos x}{\left(x \cdot x\right) \cdot \left(1 + \cos x\right)}}\]
    5. Simplified29.7

      \[\leadsto \frac{\color{blue}{\sin x \cdot \sin x}}{\left(x \cdot x\right) \cdot \left(1 + \cos x\right)}\]
    6. Using strategy rm
    7. Applied +-commutative29.7

      \[\leadsto \frac{\sin x \cdot \sin x}{\left(x \cdot x\right) \cdot \color{blue}{\left(\cos x + 1\right)}}\]
    8. Using strategy rm
    9. Applied clear-num29.7

      \[\leadsto \color{blue}{\frac{1}{\frac{\left(x \cdot x\right) \cdot \left(\cos x + 1\right)}{\sin x \cdot \sin x}}}\]
    10. Taylor expanded around 0 0.0

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{6} \cdot {x}^{2} + \left(\frac{1}{120} \cdot {x}^{4} + 2\right)}}\]
    11. Simplified0.0

      \[\leadsto \frac{1}{\color{blue}{(\frac{1}{120} \cdot \left({x}^{4}\right) + \left((\left(x \cdot x\right) \cdot \frac{1}{6} + 2)_*\right))_*}}\]

    if 0.025343046100655117 < x

    1. Initial program 0.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.009745756652596336:\\ \;\;\;\;\tan \left(\frac{x}{2}\right) \cdot \frac{\sin x}{x \cdot x}\\ \mathbf{elif}\;x \le 0.025343046100655117:\\ \;\;\;\;\frac{1}{(\frac{1}{120} \cdot \left({x}^{4}\right) + \left((\left(x \cdot x\right) \cdot \frac{1}{6} + 2)_*\right))_*}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{1 - \cos x}}{x} \cdot \frac{\sqrt{1 - \cos x}}{x}\\ \end{array}\]

Reproduce

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