Average Error: 31.2 → 0.3
Time: 28.3s
Precision: 64
Internal Precision: 2432
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.03501520358199328:\\ \;\;\;\;\frac{1}{x} \cdot \frac{1 - \cos x}{x}\\ \mathbf{if}\;x \le 3.0820637776628553 \cdot 10^{-06}:\\ \;\;\;\;\left(\frac{1}{2} + \frac{1}{720} \cdot {x}^{4}\right) - \frac{1}{24} \cdot {x}^{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\frac{\sin x \cdot \sin x}{1 + \cos x}}}{x} \cdot \frac{\sqrt{\frac{\sin x \cdot \sin x}{1 + \cos x}}}{x}\\ \end{array}\]

Error

Bits error versus x

Derivation

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

    1. Initial program 1.2

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity1.2

      \[\leadsto \frac{\color{blue}{1 \cdot \left(1 - \cos x\right)}}{x \cdot x}\]
    4. Applied times-frac0.5

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

    if -0.03501520358199328 < x < 3.0820637776628553e-06

    1. Initial program 61.7

      \[\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}}\]

    if 3.0820637776628553e-06 < x

    1. Initial program 1.4

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

      \[\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 add-sqr-sqrt1.2

      \[\leadsto \frac{\color{blue}{\sqrt{\frac{\sin x \cdot \sin x}{1 + \cos x}} \cdot \sqrt{\frac{\sin x \cdot \sin x}{1 + \cos x}}}}{x \cdot x}\]
    7. Applied times-frac0.6

      \[\leadsto \color{blue}{\frac{\sqrt{\frac{\sin x \cdot \sin x}{1 + \cos x}}}{x} \cdot \frac{\sqrt{\frac{\sin x \cdot \sin x}{1 + \cos x}}}{x}}\]
  3. Recombined 3 regimes into one program.

Runtime

Time bar (total: 28.3s)Debug logProfile

herbie shell --seed '#(1064300848 3212030778 2049303162 3567222883 2277747821 1384278011)' 
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  (/ (- 1 (cos x)) (* x x)))