Average Error: 30.8 → 0.3
Time: 45.0s
Precision: 64
Internal Precision: 2368
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;\sqrt{\frac{\tan \left(\frac{x}{2}\right)}{\frac{x \cdot x}{\sin x}}} \cdot \sqrt{\frac{\tan \left(\frac{x}{2}\right)}{\frac{x \cdot x}{\sin x}}} \le 0.11718750155867466:\\ \;\;\;\;\frac{1}{x} \cdot \frac{1 - \cos x}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{2} + \frac{1}{720} \cdot {x}^{4}\right) - \frac{1}{24} \cdot {x}^{2}\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if (* (sqrt (/ (tan (/ x 2)) (/ (* x x) (sin x)))) (sqrt (/ (tan (/ x 2)) (/ (* x x) (sin x))))) < 0.11718750155867466

    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.11718750155867466 < (* (sqrt (/ (tan (/ x 2)) (/ (* x x) (sin x)))) (sqrt (/ (tan (/ x 2)) (/ (* x x) (sin x)))))

    1. Initial program 60.9

      \[\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. Recombined 2 regimes into one program.

Runtime

Time bar (total: 45.0s)Debug logProfile

herbie shell --seed '#(1072361757 3390613284 2339397988 1175251238 145061547 3101881848)' 
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  (/ (- 1 (cos x)) (* x x)))