Average Error: 31.2 → 0.4
Time: 40.3s
Precision: 64
Internal Precision: 2368
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.011207449550947924 \lor \neg \left(x \le 0.01046868466006344\right):\\ \;\;\;\;\frac{\tan \left(\frac{x}{2}\right) \cdot \left(-\sin x\right)}{\left(-x\right) \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{720} \cdot {x}^{4} + \frac{1}{2}\right) - \frac{1}{24} \cdot {x}^{2}\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.011207449550947924 or 0.01046868466006344 < x

    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 simplify1.2

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

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

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

    if -0.011207449550947924 < x < 0.01046868466006344

    1. Initial program 61.5

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

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;x \le -0.011207449550947924 \lor \neg \left(x \le 0.01046868466006344\right):\\ \;\;\;\;\frac{\tan \left(\frac{x}{2}\right) \cdot \left(-\sin x\right)}{\left(-x\right) \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{720} \cdot {x}^{4} + \frac{1}{2}\right) - \frac{1}{24} \cdot {x}^{2}\\ \end{array}}\]

Runtime

Time bar (total: 40.3s)Debug logProfile

herbie shell --seed '#(1071948828 1180510430 2986424009 997076509 406109801 420189285)' 
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  (/ (- 1 (cos x)) (* x x)))