Average Error: 31.7 → 0.0
Time: 12.6s
Precision: binary64
\[\frac{x - \sin x}{x - \tan x} \]
\[\begin{array}{l} t_0 := x - \sin x\\ \mathbf{if}\;x \leq -0.02981343514249264:\\ \;\;\;\;\frac{t_0}{x - \frac{\sin x}{\cos x}}\\ \mathbf{elif}\;x \leq 0.029073431474603176:\\ \;\;\;\;\mathsf{fma}\left(0.225, x \cdot x, \mathsf{fma}\left({x}^{4}, -0.009642857142857142, -0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{x - \tan x}\\ \end{array} \]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
t_0 := x - \sin x\\
\mathbf{if}\;x \leq -0.02981343514249264:\\
\;\;\;\;\frac{t_0}{x - \frac{\sin x}{\cos x}}\\

\mathbf{elif}\;x \leq 0.029073431474603176:\\
\;\;\;\;\mathsf{fma}\left(0.225, x \cdot x, \mathsf{fma}\left({x}^{4}, -0.009642857142857142, -0.5\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{t_0}{x - \tan x}\\


\end{array}
(FPCore (x) :precision binary64 (/ (- x (sin x)) (- x (tan x))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (- x (sin x))))
   (if (<= x -0.02981343514249264)
     (/ t_0 (- x (/ (sin x) (cos x))))
     (if (<= x 0.029073431474603176)
       (fma 0.225 (* x x) (fma (pow x 4.0) -0.009642857142857142 -0.5))
       (/ t_0 (- x (tan x)))))))
double code(double x) {
	return (x - sin(x)) / (x - tan(x));
}
double code(double x) {
	double t_0 = x - sin(x);
	double tmp;
	if (x <= -0.02981343514249264) {
		tmp = t_0 / (x - (sin(x) / cos(x)));
	} else if (x <= 0.029073431474603176) {
		tmp = fma(0.225, (x * x), fma(pow(x, 4.0), -0.009642857142857142, -0.5));
	} else {
		tmp = t_0 / (x - tan(x));
	}
	return tmp;
}

Error

Bits error versus x

Derivation

  1. Split input into 3 regimes
  2. if x < -0.0298134351424926385

    1. Initial program 0.0

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

      \[\leadsto \frac{x - \sin x}{\color{blue}{x - \frac{\sin x}{\cos x}}} \]

    if -0.0298134351424926385 < x < 0.0290734314746031765

    1. Initial program 63.1

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

      \[\leadsto \color{blue}{0.225 \cdot {x}^{2} - \left(0.009642857142857142 \cdot {x}^{4} + 0.5\right)} \]
    3. Simplified0.0

      \[\leadsto \color{blue}{0.225 \cdot \left(x \cdot x\right) - \mathsf{fma}\left(0.009642857142857142, {x}^{4}, 0.5\right)} \]
    4. Taylor expanded in x around 0 0.0

      \[\leadsto \color{blue}{0.225 \cdot {x}^{2} - \left(0.009642857142857142 \cdot {x}^{4} + 0.5\right)} \]
    5. Simplified0.0

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

    if 0.0290734314746031765 < x

    1. Initial program 0.1

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Applied add-cube-cbrt_binary640.1

      \[\leadsto \frac{x - \sin x}{x - \color{blue}{\left(\sqrt[3]{\tan x} \cdot \sqrt[3]{\tan x}\right) \cdot \sqrt[3]{\tan x}}} \]
    3. Applied add-cube-cbrt_binary641.4

      \[\leadsto \frac{x - \sin x}{\color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}} - \left(\sqrt[3]{\tan x} \cdot \sqrt[3]{\tan x}\right) \cdot \sqrt[3]{\tan x}} \]
    4. Applied prod-diff_binary641.4

      \[\leadsto \frac{x - \sin x}{\color{blue}{\mathsf{fma}\left(\sqrt[3]{x} \cdot \sqrt[3]{x}, \sqrt[3]{x}, -\sqrt[3]{\tan x} \cdot \left(\sqrt[3]{\tan x} \cdot \sqrt[3]{\tan x}\right)\right) + \mathsf{fma}\left(-\sqrt[3]{\tan x}, \sqrt[3]{\tan x} \cdot \sqrt[3]{\tan x}, \sqrt[3]{\tan x} \cdot \left(\sqrt[3]{\tan x} \cdot \sqrt[3]{\tan x}\right)\right)}} \]
    5. Simplified0.1

      \[\leadsto \frac{x - \sin x}{\color{blue}{\left(x - \tan x\right)} + \mathsf{fma}\left(-\sqrt[3]{\tan x}, \sqrt[3]{\tan x} \cdot \sqrt[3]{\tan x}, \sqrt[3]{\tan x} \cdot \left(\sqrt[3]{\tan x} \cdot \sqrt[3]{\tan x}\right)\right)} \]
    6. Simplified0.1

      \[\leadsto \frac{x - \sin x}{\left(x - \tan x\right) + \color{blue}{0}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.02981343514249264:\\ \;\;\;\;\frac{x - \sin x}{x - \frac{\sin x}{\cos x}}\\ \mathbf{elif}\;x \leq 0.029073431474603176:\\ \;\;\;\;\mathsf{fma}\left(0.225, x \cdot x, \mathsf{fma}\left({x}^{4}, -0.009642857142857142, -0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \end{array} \]

Reproduce

herbie shell --seed 2022024 
(FPCore (x)
  :name "sintan (problem 3.4.5)"
  :precision binary64
  (/ (- x (sin x)) (- x (tan x))))