?

Average Error: 29.9 → 0.0
Time: 25.8s
Precision: binary64
Cost: 13312

?

\[-0.01 \leq x \land x \leq 0.01\]
\[1 - \cos x \]
\[\mathsf{fma}\left(x \cdot 0.5, x, {x}^{4} \cdot -0.041666666666666664\right) \]
(FPCore (x) :precision binary64 (- 1.0 (cos x)))
(FPCore (x)
 :precision binary64
 (fma (* x 0.5) x (* (pow x 4.0) -0.041666666666666664)))
double code(double x) {
	return 1.0 - cos(x);
}
double code(double x) {
	return fma((x * 0.5), x, (pow(x, 4.0) * -0.041666666666666664));
}
function code(x)
	return Float64(1.0 - cos(x))
end
function code(x)
	return fma(Float64(x * 0.5), x, Float64((x ^ 4.0) * -0.041666666666666664))
end
code[x_] := N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(x * 0.5), $MachinePrecision] * x + N[(N[Power[x, 4.0], $MachinePrecision] * -0.041666666666666664), $MachinePrecision]), $MachinePrecision]
1 - \cos x
\mathsf{fma}\left(x \cdot 0.5, x, {x}^{4} \cdot -0.041666666666666664\right)

Error?

Target

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

Derivation?

  1. Initial program 29.9

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

    \[\leadsto \color{blue}{0.5 \cdot {x}^{2} + -0.041666666666666664 \cdot {x}^{4}} \]
  3. Simplified0.0

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

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

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

Alternatives

Alternative 1
Error0.1
Cost6976
\[\mathsf{fma}\left(-0.041666666666666664, x \cdot x, 0.5\right) \cdot \left(x \cdot x\right) \]
Alternative 2
Error0.3
Cost320
\[0.5 \cdot \left(x \cdot x\right) \]

Error

Reproduce?

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