Average Error: 30.8 → 0.3
Time: 20.0s
Precision: 64
Internal Precision: 2368
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.028147938555863415:\\ \;\;\;\;\frac{\frac{1 - \cos x}{x}}{x}\\ \mathbf{elif}\;x \le 1.3399824791222602 \cdot 10^{-23}:\\ \;\;\;\;(\frac{1}{720} \cdot \left({x}^{4}\right) + \left((\left(\frac{-1}{24} \cdot x\right) \cdot x + \frac{1}{2})_*\right))_*\\ \mathbf{else}:\\ \;\;\;\;\tan \left(\frac{x}{2}\right) \cdot \frac{\sin x}{x \cdot x}\\ \end{array}\]

Error

Bits error versus x

Derivation

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

    1. Initial program 0.9

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Initial simplification0.9

      \[\leadsto \frac{1 - \cos x}{x \cdot x}\]
    3. Using strategy rm
    4. Applied associate-/r*0.5

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

    if -0.028147938555863415 < x < 1.3399824791222602e-23

    1. Initial program 61.7

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Initial simplification61.7

      \[\leadsto \frac{1 - \cos x}{x \cdot x}\]
    3. Using strategy rm
    4. Applied flip--61.7

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

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

      \[\leadsto \frac{\color{blue}{\sin x \cdot \sin x}}{\left(x \cdot x\right) \cdot \left(1 + \cos x\right)}\]
    7. Using strategy rm
    8. Applied expm1-log1p-u31.0

      \[\leadsto \frac{\color{blue}{(e^{\log_* (1 + \sin x \cdot \sin x)} - 1)^*}}{\left(x \cdot x\right) \cdot \left(1 + \cos x\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))_*}\]

    if 1.3399824791222602e-23 < x

    1. Initial program 4.0

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Initial simplification4.0

      \[\leadsto \frac{1 - \cos x}{x \cdot x}\]
    3. Using strategy rm
    4. Applied flip--4.2

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

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

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

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

      \[\leadsto \frac{\sin x}{x \cdot x} \cdot \color{blue}{\tan \left(\frac{x}{2}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.028147938555863415:\\ \;\;\;\;\frac{\frac{1 - \cos x}{x}}{x}\\ \mathbf{elif}\;x \le 1.3399824791222602 \cdot 10^{-23}:\\ \;\;\;\;(\frac{1}{720} \cdot \left({x}^{4}\right) + \left((\left(\frac{-1}{24} \cdot x\right) \cdot x + \frac{1}{2})_*\right))_*\\ \mathbf{else}:\\ \;\;\;\;\tan \left(\frac{x}{2}\right) \cdot \frac{\sin x}{x \cdot x}\\ \end{array}\]

Runtime

Time bar (total: 20.0s)Debug logProfile

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