Average Error: 31.8 → 0.1
Time: 5.1s
Precision: binary64
\[\frac{1 - \cos x}{x \cdot x} \]
\[\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin x \cdot \frac{\tan \left(\frac{x}{2}\right)}{x}}{x}\right)\right) \]
\frac{1 - \cos x}{x \cdot x}
\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin x \cdot \frac{\tan \left(\frac{x}{2}\right)}{x}}{x}\right)\right)
(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (* x x)))
(FPCore (x)
 :precision binary64
 (expm1 (log1p (/ (* (sin x) (/ (tan (/ x 2.0)) x)) x))))
double code(double x) {
	return (1.0 - cos(x)) / (x * x);
}
double code(double x) {
	return expm1(log1p((sin(x) * (tan(x / 2.0) / x)) / x));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 31.8

    \[\frac{1 - \cos x}{x \cdot x} \]
  2. Applied flip--_binary6431.9

    \[\leadsto \frac{\color{blue}{\frac{1 \cdot 1 - \cos x \cdot \cos x}{1 + \cos x}}}{x \cdot x} \]
  3. Simplified15.6

    \[\leadsto \frac{\frac{\color{blue}{\sin x \cdot \sin x}}{1 + \cos x}}{x \cdot x} \]
  4. Applied *-un-lft-identity_binary6415.6

    \[\leadsto \frac{\color{blue}{1 \cdot \frac{\sin x \cdot \sin x}{1 + \cos x}}}{x \cdot x} \]
  5. Applied times-frac_binary6415.1

    \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{\frac{\sin x \cdot \sin x}{1 + \cos x}}{x}} \]
  6. Simplified0.2

    \[\leadsto \frac{1}{x} \cdot \color{blue}{\left(\frac{\sin x}{x} \cdot \tan \left(\frac{x}{2}\right)\right)} \]
  7. Applied div-inv_binary640.3

    \[\leadsto \frac{1}{x} \cdot \left(\color{blue}{\left(\sin x \cdot \frac{1}{x}\right)} \cdot \tan \left(\frac{x}{2}\right)\right) \]
  8. Applied associate-*l*_binary640.3

    \[\leadsto \frac{1}{x} \cdot \color{blue}{\left(\sin x \cdot \left(\frac{1}{x} \cdot \tan \left(\frac{x}{2}\right)\right)\right)} \]
  9. Simplified0.2

    \[\leadsto \frac{1}{x} \cdot \left(\sin x \cdot \color{blue}{\frac{\tan \left(\frac{x}{2}\right)}{x}}\right) \]
  10. Applied expm1-log1p-u_binary640.2

    \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{x} \cdot \left(\sin x \cdot \frac{\tan \left(\frac{x}{2}\right)}{x}\right)\right)\right)} \]
  11. Simplified0.1

    \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\frac{\sin x \cdot \frac{\tan \left(\frac{x}{2}\right)}{x}}{x}\right)}\right) \]
  12. Final simplification0.1

    \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin x \cdot \frac{\tan \left(\frac{x}{2}\right)}{x}}{x}\right)\right) \]

Reproduce

herbie shell --seed 2022068 
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  :precision binary64
  (/ (- 1.0 (cos x)) (* x x)))