Average Error: 30.0 → 0.0
Time: 4.7s
Precision: binary64
\[-0.01 \leq x \land x \leq 0.01\]
\[1 - \cos x \]
\[\mathsf{fma}\left({x}^{6}, 0.001388888888888889, \mathsf{fma}\left(x, x \cdot 0.5, {x}^{4} \cdot -0.041666666666666664\right)\right) \]
(FPCore (x) :precision binary64 (- 1.0 (cos x)))
(FPCore (x)
 :precision binary64
 (fma
  (pow x 6.0)
  0.001388888888888889
  (fma x (* x 0.5) (* (pow x 4.0) -0.041666666666666664))))
double code(double x) {
	return 1.0 - cos(x);
}
double code(double x) {
	return fma(pow(x, 6.0), 0.001388888888888889, fma(x, (x * 0.5), (pow(x, 4.0) * -0.041666666666666664)));
}
function code(x)
	return Float64(1.0 - cos(x))
end
function code(x)
	return fma((x ^ 6.0), 0.001388888888888889, fma(x, Float64(x * 0.5), Float64((x ^ 4.0) * -0.041666666666666664)))
end
code[x_] := N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[Power[x, 6.0], $MachinePrecision] * 0.001388888888888889 + N[(x * N[(x * 0.5), $MachinePrecision] + N[(N[Power[x, 4.0], $MachinePrecision] * -0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
1 - \cos x
\mathsf{fma}\left({x}^{6}, 0.001388888888888889, \mathsf{fma}\left(x, x \cdot 0.5, {x}^{4} \cdot -0.041666666666666664\right)\right)

Error

Bits error versus x

Target

Original30.0
Target0.0
Herbie0.0
\[\frac{\sin x \cdot \sin x}{1 + \cos x} \]

Derivation

  1. Initial program 30.0

    \[1 - \cos x \]
  2. Taylor expanded in x around 0 0.0

    \[\leadsto \color{blue}{\left(0.001388888888888889 \cdot {x}^{6} + 0.5 \cdot {x}^{2}\right) - 0.041666666666666664 \cdot {x}^{4}} \]
  3. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, -0.041666666666666664, 0.5\right), 0.001388888888888889 \cdot {x}^{6}\right)} \]
  4. Applied egg-rr0.3

    \[\leadsto \color{blue}{{\left(\sqrt{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, -0.041666666666666664, 0.5\right), 0.001388888888888889 \cdot {x}^{6}\right)}\right)}^{2}} \]
  5. Taylor expanded in x around 0 0.6

    \[\leadsto \color{blue}{\left(0.001388888888888889 \cdot {x}^{6} + {\left(\sqrt{0.5}\right)}^{2} \cdot {x}^{2}\right) - 0.041666666666666664 \cdot {x}^{4}} \]
  6. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left({x}^{6}, 0.001388888888888889, \mathsf{fma}\left(x, x \cdot 0.5, {x}^{4} \cdot -0.041666666666666664\right)\right)} \]
  7. Final simplification0.0

    \[\leadsto \mathsf{fma}\left({x}^{6}, 0.001388888888888889, \mathsf{fma}\left(x, x \cdot 0.5, {x}^{4} \cdot -0.041666666666666664\right)\right) \]

Reproduce

herbie shell --seed 2022160 
(FPCore (x)
  :name "ENA, Section 1.4, Mentioned, A"
  :precision binary64
  :pre (and (<= -0.01 x) (<= x 0.01))

  :herbie-target
  (/ (* (sin x) (sin x)) (+ 1.0 (cos x)))

  (- 1.0 (cos x)))