Average Error: 31.0 → 0.3
Time: 22.4s
Precision: 64
Internal precision: 128
\[\frac{1 - \cos x}{{x}^2}\]
\[\begin{array}{l} \mathbf{if}\;x \le -5.458497096453193 \cdot 10^{-06}:\\ \;\;\;\;\frac{1}{x} \cdot \frac{1 - \cos x}{x}\\ \mathbf{if}\;x \le 85.36504497937187:\\ \;\;\;\;\left(\frac{1}{2} + \frac{1}{720} \cdot {x}^{4}\right) - \frac{1}{24} \cdot {x}^2\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x} \cdot \frac{1 - \cos x}{x}\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes.
  2. if x < -5.458497096453193e-06 or 85.36504497937187 < x

    1. Initial program 1.2

      \[\frac{1 - \cos x}{{x}^2}\]
    2. Using strategy rm
    3. Applied square-mult 1.2

      \[\leadsto \frac{1 - \cos x}{\color{blue}{x \cdot x}}\]
    4. Applied *-un-lft-identity 1.2

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

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

    if -5.458497096453193e-06 < x < 85.36504497937187

    1. Initial program 61.4

      \[\frac{1 - \cos x}{{x}^2}\]
    2. Applied taylor 0.0

      \[\leadsto \left(\frac{1}{2} + \frac{1}{720} \cdot {x}^{4}\right) - \frac{1}{24} \cdot {x}^2\]
    3. 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. Removed slow pow expressions

Runtime

Time bar (total: 22.4s) Debug log

Please include this information when filing a bug report:

herbie --seed '#(2450642636 2863344379 4098708838 1734408276 15201110 2842944231)'
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  (/ (- 1 (cos x)) (sqr x)))