Average Error: 30.4 → 0.4
Time: 13.5s
Precision: binary64
\[-1 \leq x \land x \leq 1\]
\[\frac{x - \sin x}{\tan x} \]
\[x \cdot \left(x \cdot \mathsf{fma}\left(x \cdot x, -0.06388888888888888, 0.16666666666666666\right)\right) \]
\frac{x - \sin x}{\tan x}
x \cdot \left(x \cdot \mathsf{fma}\left(x \cdot x, -0.06388888888888888, 0.16666666666666666\right)\right)
(FPCore (x) :precision binary64 (/ (- x (sin x)) (tan x)))
(FPCore (x)
 :precision binary64
 (* x (* x (fma (* x x) -0.06388888888888888 0.16666666666666666))))
double code(double x) {
	return (x - sin(x)) / tan(x);
}
double code(double x) {
	return x * (x * fma((x * x), -0.06388888888888888, 0.16666666666666666));
}

Error

Bits error versus x

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.5

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

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

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

Reproduce

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