Average Error: 30.5 → 0.0
Time: 6.3s
Precision: binary64
\[\frac{1 - \cos x}{\sin x} \]
\[\tan \left(\frac{x}{2}\right) \]
\frac{1 - \cos x}{\sin x}
\tan \left(\frac{x}{2}\right)
(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (sin x)))
(FPCore (x) :precision binary64 (tan (/ x 2.0)))
double code(double x) {
	return (1.0 - cos(x)) / sin(x);
}
double code(double x) {
	return tan(x / 2.0);
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original30.5
Target0.0
Herbie0.0
\[\tan \left(\frac{x}{2}\right) \]

Derivation

  1. Initial program 30.5

    \[\frac{1 - \cos x}{\sin x} \]
  2. Simplified0.0

    \[\leadsto \color{blue}{\tan \left(\frac{x}{2}\right)} \]
  3. Final simplification0.0

    \[\leadsto \tan \left(\frac{x}{2}\right) \]

Reproduce

herbie shell --seed 2021196 
(FPCore (x)
  :name "tanhf (example 3.4)"
  :precision binary64

  :herbie-target
  (tan (/ x 2.0))

  (/ (- 1.0 (cos x)) (sin x)))