Average Error: 31.5 → 0.3
Time: 21.5s
Precision: 64
Internal Precision: 2368
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.030807747097317043 \lor \neg \left(x \le 0.03387160511529298\right):\\ \;\;\;\;\frac{\frac{1 - \cos x}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;\left({x}^{4} \cdot \frac{1}{720} + \frac{1}{2}\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.030807747097317043 or 0.03387160511529298 < x

    1. Initial program 1.1

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Using strategy rm
    3. Applied associate-/r*0.5

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

    if -0.030807747097317043 < x < 0.03387160511529298

    1. Initial program 61.4

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

      \[\leadsto \frac{\color{blue}{\frac{1 \cdot 1 - \cos x \cdot \cos x}{1 + \cos x}}}{x \cdot x}\]
    4. Applied associate-/l/61.4

      \[\leadsto \color{blue}{\frac{1 \cdot 1 - \cos x \cdot \cos x}{\left(x \cdot x\right) \cdot \left(1 + \cos x\right)}}\]
    5. Simplified29.9

      \[\leadsto \frac{\color{blue}{\sin x \cdot \sin x}}{\left(x \cdot x\right) \cdot \left(1 + \cos x\right)}\]
    6. 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. Final simplification0.3

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

Runtime

Time bar (total: 21.5s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes15.60.30.015.698.5%
herbie shell --seed 2018340 
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  (/ (- 1 (cos x)) (* x x)))