Average Error: 31.4 → 0.4
Time: 44.8s
Precision: 64
Internal Precision: 2368
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.028862514643729777:\\ \;\;\;\;\frac{\log \left(e^{1 - \cos x}\right)}{x \cdot x}\\ \mathbf{elif}\;x \le 0.03548345551390503:\\ \;\;\;\;(\frac{1}{720} \cdot \left({x}^{4}\right) + \left((\left(\frac{-1}{24} \cdot x\right) \cdot x + \frac{1}{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.028862514643729777

    1. Initial program 1.0

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

      \[\leadsto \frac{1 - \cos x}{x \cdot x}\]
    3. Using strategy rm
    4. Applied add-log-exp1.1

      \[\leadsto \frac{\color{blue}{\log \left(e^{1 - \cos x}\right)}}{x \cdot x}\]

    if -0.028862514643729777 < x < 0.03548345551390503

    1. Initial program 61.3

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

      \[\leadsto \frac{1 - \cos x}{x \cdot x}\]
    3. 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}}\]
    4. 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 0.03548345551390503 < x

    1. Initial program 1.1

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

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

      \[\leadsto \frac{\color{blue}{\sqrt{1 - \cos x} \cdot \sqrt{1 - \cos x}}}{x \cdot x}\]
    5. 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.028862514643729777:\\ \;\;\;\;\frac{\log \left(e^{1 - \cos x}\right)}{x \cdot x}\\ \mathbf{elif}\;x \le 0.03548345551390503:\\ \;\;\;\;(\frac{1}{720} \cdot \left({x}^{4}\right) + \left((\left(\frac{-1}{24} \cdot x\right) \cdot x + \frac{1}{2})_*\right))_*\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{1 - \cos x}}{x} \cdot \frac{\sqrt{1 - \cos x}}{x}\\ \end{array}\]

Runtime

Time bar (total: 44.8s)Debug logProfile

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