?

Average Error: 30.1 → 0.0
Time: 7.4s
Precision: binary64
Cost: 6976

?

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

Error?

Target

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

Derivation?

  1. Initial program 30.1

    \[1 - \cos x \]
  2. Applied egg-rr0.0

    \[\leadsto \color{blue}{\left(\sin x \cdot \sin x\right) \cdot \frac{1}{1 + \cos x}} \]
  3. Simplified0.0

    \[\leadsto \color{blue}{\sin x \cdot \tan \left(\frac{x}{2}\right)} \]
    Proof

    [Start]0.0

    \[ \left(\sin x \cdot \sin x\right) \cdot \frac{1}{1 + \cos x} \]

    associate-*r/ [=>]0.0

    \[ \color{blue}{\frac{\left(\sin x \cdot \sin x\right) \cdot 1}{1 + \cos x}} \]

    *-rgt-identity [=>]0.0

    \[ \frac{\color{blue}{\sin x \cdot \sin x}}{1 + \cos x} \]

    associate-*r/ [<=]0.0

    \[ \color{blue}{\sin x \cdot \frac{\sin x}{1 + \cos x}} \]

    hang-0p-tan [=>]0.0

    \[ \sin x \cdot \color{blue}{\tan \left(\frac{x}{2}\right)} \]
  4. Taylor expanded in x around 0 0.0

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

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

    [Start]0.0

    \[ 0.5 \cdot {x}^{2} + -0.041666666666666664 \cdot {x}^{4} \]

    +-commutative [=>]0.0

    \[ \color{blue}{-0.041666666666666664 \cdot {x}^{4} + 0.5 \cdot {x}^{2}} \]

    *-commutative [=>]0.0

    \[ \color{blue}{{x}^{4} \cdot -0.041666666666666664} + 0.5 \cdot {x}^{2} \]

    metadata-eval [<=]0.0

    \[ {x}^{\color{blue}{\left(2 \cdot 2\right)}} \cdot -0.041666666666666664 + 0.5 \cdot {x}^{2} \]

    pow-sqr [<=]0.0

    \[ \color{blue}{\left({x}^{2} \cdot {x}^{2}\right)} \cdot -0.041666666666666664 + 0.5 \cdot {x}^{2} \]

    associate-*l* [=>]0.0

    \[ \color{blue}{{x}^{2} \cdot \left({x}^{2} \cdot -0.041666666666666664\right)} + 0.5 \cdot {x}^{2} \]

    *-commutative [=>]0.0

    \[ {x}^{2} \cdot \left({x}^{2} \cdot -0.041666666666666664\right) + \color{blue}{{x}^{2} \cdot 0.5} \]

    distribute-lft-out [=>]0.0

    \[ \color{blue}{{x}^{2} \cdot \left({x}^{2} \cdot -0.041666666666666664 + 0.5\right)} \]

    unpow2 [=>]0.0

    \[ \color{blue}{\left(x \cdot x\right)} \cdot \left({x}^{2} \cdot -0.041666666666666664 + 0.5\right) \]

    unpow2 [=>]0.0

    \[ \left(x \cdot x\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot -0.041666666666666664 + 0.5\right) \]

    associate-*l* [=>]0.0

    \[ \left(x \cdot x\right) \cdot \left(\color{blue}{x \cdot \left(x \cdot -0.041666666666666664\right)} + 0.5\right) \]

    fma-def [=>]0.0

    \[ \left(x \cdot x\right) \cdot \color{blue}{\mathsf{fma}\left(x, x \cdot -0.041666666666666664, 0.5\right)} \]
  6. Taylor expanded in x around 0 0.0

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

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

    [Start]0.0

    \[ 0.5 \cdot {x}^{2} + -0.041666666666666664 \cdot {x}^{4} \]

    *-commutative [=>]0.0

    \[ \color{blue}{{x}^{2} \cdot 0.5} + -0.041666666666666664 \cdot {x}^{4} \]

    unpow2 [=>]0.0

    \[ \color{blue}{\left(x \cdot x\right)} \cdot 0.5 + -0.041666666666666664 \cdot {x}^{4} \]

    *-commutative [=>]0.0

    \[ \left(x \cdot x\right) \cdot 0.5 + \color{blue}{{x}^{4} \cdot -0.041666666666666664} \]

    metadata-eval [<=]0.0

    \[ \left(x \cdot x\right) \cdot 0.5 + {x}^{\color{blue}{\left(2 \cdot 2\right)}} \cdot -0.041666666666666664 \]

    pow-sqr [<=]0.0

    \[ \left(x \cdot x\right) \cdot 0.5 + \color{blue}{\left({x}^{2} \cdot {x}^{2}\right)} \cdot -0.041666666666666664 \]

    unpow2 [=>]0.0

    \[ \left(x \cdot x\right) \cdot 0.5 + \left(\color{blue}{\left(x \cdot x\right)} \cdot {x}^{2}\right) \cdot -0.041666666666666664 \]

    unpow2 [=>]0.0

    \[ \left(x \cdot x\right) \cdot 0.5 + \left(\left(x \cdot x\right) \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot -0.041666666666666664 \]

    associate-*r* [<=]0.0

    \[ \left(x \cdot x\right) \cdot 0.5 + \color{blue}{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot -0.041666666666666664\right)} \]

    associate-*r* [<=]0.0

    \[ \left(x \cdot x\right) \cdot 0.5 + \left(x \cdot x\right) \cdot \color{blue}{\left(x \cdot \left(x \cdot -0.041666666666666664\right)\right)} \]

    distribute-lft-out [=>]0.0

    \[ \color{blue}{\left(x \cdot x\right) \cdot \left(0.5 + x \cdot \left(x \cdot -0.041666666666666664\right)\right)} \]

    +-commutative [<=]0.0

    \[ \left(x \cdot x\right) \cdot \color{blue}{\left(x \cdot \left(x \cdot -0.041666666666666664\right) + 0.5\right)} \]

    fma-udef [<=]0.0

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

    associate-*r* [<=]0.0

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

    *-commutative [=>]0.0

    \[ x \cdot \left(x \cdot \mathsf{fma}\left(x, \color{blue}{-0.041666666666666664 \cdot x}, 0.5\right)\right) \]
  8. Final simplification0.0

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

Alternatives

Alternative 1
Error0.0
Cost832
\[x \cdot \left(x \cdot \left(x \cdot \left(x \cdot -0.041666666666666664\right)\right) + x \cdot 0.5\right) \]
Alternative 2
Error0.7
Cost576
\[\frac{1}{0.16666666666666666 + \frac{2}{x \cdot x}} \]
Alternative 3
Error0.3
Cost320
\[0.5 \cdot \left(x \cdot x\right) \]
Alternative 4
Error61.4
Cost64
\[6 \]

Error

Reproduce?

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