Average Error: 30.6 → 0.1
Time: 17.2s
Precision: 64
Internal Precision: 2368
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.011828750465139893 \lor \neg \left(x \le 4.531730902422679 \cdot 10^{-05}\right):\\ \;\;\;\;\frac{\frac{\sin x \cdot \tan \left(\frac{x}{2}\right)}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;(\frac{1}{720} \cdot \left({x}^{4}\right) + \left((\left(\frac{-1}{24} \cdot x\right) \cdot x + \frac{1}{2})_*\right))_*\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.011828750465139893 or 4.531730902422679e-05 < x

    1. Initial program 1.2

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

      \[\leadsto \frac{\color{blue}{\frac{1 \cdot 1 - \cos x \cdot \cos x}{1 + \cos x}}}{x \cdot x}\]
    4. Applied associate-/l/1.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. Simplified1.2

      \[\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 times-frac1.1

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

      \[\leadsto \frac{\sin x}{x \cdot x} \cdot \color{blue}{\tan \left(\frac{x}{2}\right)}\]
    9. Using strategy rm
    10. Applied associate-*l/0.8

      \[\leadsto \color{blue}{\frac{\sin x \cdot \tan \left(\frac{x}{2}\right)}{x \cdot x}}\]
    11. Using strategy rm
    12. Applied associate-/r*0.2

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

    if -0.011828750465139893 < x < 4.531730902422679e-05

    1. Initial program 61.6

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

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

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

      \[\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 times-frac30.7

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

      \[\leadsto \frac{\sin x}{x \cdot x} \cdot \color{blue}{\tan \left(\frac{x}{2}\right)}\]
    9. 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}}\]
    10. Simplified0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.011828750465139893 \lor \neg \left(x \le 4.531730902422679 \cdot 10^{-05}\right):\\ \;\;\;\;\frac{\frac{\sin x \cdot \tan \left(\frac{x}{2}\right)}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;(\frac{1}{720} \cdot \left({x}^{4}\right) + \left((\left(\frac{-1}{24} \cdot x\right) \cdot x + \frac{1}{2})_*\right))_*\\ \end{array}\]

Runtime

Time bar (total: 17.2s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes15.00.10.015.099.4%
herbie shell --seed 2018286 +o rules:numerics
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  (/ (- 1 (cos x)) (* x x)))