Average Error: 30.3 → 0.3
Time: 15.4s
Precision: binary64
\[-1 \leq x \land x \leq 1\]
\[\frac{x - \sin x}{\tan x} \]
\[\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, -0.06388888888888888, 0.16666666666666666\right), \mathsf{fma}\left({x}^{8}, -0.00023644179894179894, {x}^{6} \cdot -0.0007275132275132275\right)\right) \]
(FPCore (x) :precision binary64 (/ (- x (sin x)) (tan x)))
(FPCore (x)
 :precision binary64
 (fma
  (* x x)
  (fma (* x x) -0.06388888888888888 0.16666666666666666)
  (fma
   (pow x 8.0)
   -0.00023644179894179894
   (* (pow x 6.0) -0.0007275132275132275))))
double code(double x) {
	return (x - sin(x)) / tan(x);
}
double code(double x) {
	return fma((x * x), fma((x * x), -0.06388888888888888, 0.16666666666666666), fma(pow(x, 8.0), -0.00023644179894179894, (pow(x, 6.0) * -0.0007275132275132275)));
}
function code(x)
	return Float64(Float64(x - sin(x)) / tan(x))
end
function code(x)
	return fma(Float64(x * x), fma(Float64(x * x), -0.06388888888888888, 0.16666666666666666), fma((x ^ 8.0), -0.00023644179894179894, Float64((x ^ 6.0) * -0.0007275132275132275)))
end
code[x_] := N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Tan[x], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * -0.06388888888888888 + 0.16666666666666666), $MachinePrecision] + N[(N[Power[x, 8.0], $MachinePrecision] * -0.00023644179894179894 + N[(N[Power[x, 6.0], $MachinePrecision] * -0.0007275132275132275), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x - \sin x}{\tan x}
\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, -0.06388888888888888, 0.16666666666666666\right), \mathsf{fma}\left({x}^{8}, -0.00023644179894179894, {x}^{6} \cdot -0.0007275132275132275\right)\right)

Error

Bits error versus x

Target

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

Derivation

  1. Initial program 30.3

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

    \[\leadsto \color{blue}{0.16666666666666666 \cdot {x}^{2} - \left(0.06388888888888888 \cdot {x}^{4} + \left(0.0007275132275132275 \cdot {x}^{6} + 0.00023644179894179894 \cdot {x}^{8}\right)\right)} \]
  3. Simplified0.3

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

    \[\leadsto \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, -0.06388888888888888, 0.16666666666666666\right), \mathsf{fma}\left({x}^{8}, -0.00023644179894179894, {x}^{6} \cdot -0.0007275132275132275\right)\right) \]

Reproduce

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