Average Error: 30.4 → 0.4
Time: 13.7s
Precision: binary64
\[-1 \leq x \land x \leq 1\]
\[\frac{x - \sin x}{\tan x} \]
\[\mathsf{fma}\left(x, x \cdot 0.16666666666666666, {x}^{4} \cdot -0.06388888888888888\right) \]
(FPCore (x) :precision binary64 (/ (- x (sin x)) (tan x)))
(FPCore (x)
 :precision binary64
 (fma x (* x 0.16666666666666666) (* (pow x 4.0) -0.06388888888888888)))
double code(double x) {
	return (x - sin(x)) / tan(x);
}
double code(double x) {
	return fma(x, (x * 0.16666666666666666), (pow(x, 4.0) * -0.06388888888888888));
}
function code(x)
	return Float64(Float64(x - sin(x)) / tan(x))
end
function code(x)
	return fma(x, Float64(x * 0.16666666666666666), Float64((x ^ 4.0) * -0.06388888888888888))
end
code[x_] := N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Tan[x], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(x * N[(x * 0.16666666666666666), $MachinePrecision] + N[(N[Power[x, 4.0], $MachinePrecision] * -0.06388888888888888), $MachinePrecision]), $MachinePrecision]
\frac{x - \sin x}{\tan x}
\mathsf{fma}\left(x, x \cdot 0.16666666666666666, {x}^{4} \cdot -0.06388888888888888\right)

Error

Target

Original30.4
Target0.9
Herbie0.4
\[0.16666666666666666 \cdot \left(x \cdot x\right) \]

Derivation

  1. Initial program 30.4

    \[\frac{x - \sin x}{\tan x} \]
  2. Taylor expanded in x around 0 0.4

    \[\leadsto \color{blue}{0.16666666666666666 \cdot {x}^{2} + -0.06388888888888888 \cdot {x}^{4}} \]
  3. Simplified0.4

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

    \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(0.16666666666666666, x \cdot x, -0.06388888888888888 \cdot {x}^{4}\right)} \cdot \sqrt{\mathsf{fma}\left(0.16666666666666666, x \cdot x, -0.06388888888888888 \cdot {x}^{4}\right)}} \]
  5. Applied egg-rr0.6

    \[\leadsto \sqrt{\mathsf{fma}\left(0.16666666666666666, x \cdot x, -0.06388888888888888 \cdot {x}^{4}\right)} \cdot \color{blue}{{\left({\left(\mathsf{fma}\left(0.16666666666666666, x \cdot x, -0.06388888888888888 \cdot {x}^{4}\right)\right)}^{0.25}\right)}^{2}} \]
  6. Taylor expanded in x around 0 0.4

    \[\leadsto \color{blue}{0.16666666666666666 \cdot {x}^{2} + -0.06388888888888888 \cdot {x}^{4}} \]
  7. Simplified0.4

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x \cdot 0.16666666666666666, {x}^{4} \cdot -0.06388888888888888\right)} \]
  8. Final simplification0.4

    \[\leadsto \mathsf{fma}\left(x, x \cdot 0.16666666666666666, {x}^{4} \cdot -0.06388888888888888\right) \]

Reproduce

herbie shell --seed 2022190 
(FPCore (x)
  :name "ENA, Section 1.4, Exercise 4a"
  :precision binary64
  :pre (and (<= -1.0 x) (<= x 1.0))

  :herbie-target
  (* 0.16666666666666666 (* x x))

  (/ (- x (sin x)) (tan x)))