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

Error

Target

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

Derivation

  1. Initial program 29.7

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

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

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

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

Reproduce

herbie shell --seed 2022210 
(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)))