Average Error: 31.1 → 0.5
Time: 1.3m
Precision: 64
Internal Precision: 2368
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;\sqrt[3]{\frac{\tan \left(\frac{x}{2}\right) \cdot \left(\sin x \cdot \sin x\right)}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} \cdot \frac{\tan \left(\frac{x}{2}\right) \cdot \left(\sin x \cdot \sin x\right)}{\left(x \cdot x\right) \cdot \left(1 + \cos x\right)}} \le 0.05825629460480939:\\ \;\;\;\;\frac{\sqrt[3]{1 - \cos x} \cdot \sqrt[3]{1 - \cos x}}{x} \cdot \frac{\sqrt[3]{1 - \cos x}}{x}\\ \mathbf{else}:\\ \;\;\;\;(\left({x}^{4}\right) \cdot \frac{1}{720} + \frac{1}{2})_* - x \cdot \left(\frac{1}{24} \cdot x\right)\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if (cbrt (* (/ (* (tan (/ x 2)) (* (sin x) (sin x))) (* (* x x) (* x x))) (/ (* (tan (/ x 2)) (* (sin x) (sin x))) (* (* x x) (+ 1 (cos x)))))) < 0.05825629460480939

    1. Initial program 1.1

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt1.5

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

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

    if 0.05825629460480939 < (cbrt (* (/ (* (tan (/ x 2)) (* (sin x) (sin x))) (* (* x x) (* x x))) (/ (* (tan (/ x 2)) (* (sin x) (sin x))) (* (* x x) (+ 1 (cos x))))))

    1. Initial program 61.0

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

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

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

Runtime

Time bar (total: 1.3m)Debug logProfile

herbie shell --seed 2018201 +o rules:numerics
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  (/ (- 1 (cos x)) (* x x)))