Average Error: 30.7 → 0.3
Time: 1.1m
Precision: 64
Internal Precision: 2368
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.033966867866531136 \lor \neg \left(x \le 0.029704376882507127\right):\\ \;\;\;\;\frac{1}{x} \cdot \frac{1 - \cos x}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{2} + {x}^{4} \cdot \frac{1}{720}\right) - \frac{1}{24} \cdot {x}^{2}\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if x < -0.033966867866531136 or 0.029704376882507127 < x

    1. Initial program 1.0

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

      \[\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.033966867866531136 < x < 0.029704376882507127

    1. Initial program 61.3

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. 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}}\]
  3. Recombined 2 regimes into one program.
  4. Applied simplify0.3

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

Runtime

Time bar (total: 1.1m)Debug logProfile

herbie shell --seed 2020178 
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  (/ (- 1 (cos x)) (* x x)))