Average Error: 32.3 → 0.2
Time: 12.4s
Precision: binary64
\[\frac{x - \sin x}{x - \tan x} \]
\[\begin{array}{l} t_0 := \frac{\sin x}{\cos x}\\ \mathbf{if}\;x \leq -0.03232663999321673:\\ \;\;\;\;\frac{x - \sin x}{x - t_0}\\ \mathbf{elif}\;x \leq 2.6632315197980545:\\ \;\;\;\;0.225 \cdot \left(x \cdot x\right) - \mathsf{fma}\left(0.009642857142857142, {x}^{4}, 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{t_0 - \sin x}{x}\\ \end{array} \]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
t_0 := \frac{\sin x}{\cos x}\\
\mathbf{if}\;x \leq -0.03232663999321673:\\
\;\;\;\;\frac{x - \sin x}{x - t_0}\\

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

\mathbf{else}:\\
\;\;\;\;1 + \frac{t_0 - \sin x}{x}\\


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

Error

Bits error versus x

Derivation

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

    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.0323266399932167284 < x < 2.6632315197980545

    1. Initial program 63.0

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

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

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

    if 2.6632315197980545 < x

    1. Initial program 0.0

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

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

      \[\leadsto \color{blue}{1 + \frac{\sin x}{x} \cdot \left(\frac{1}{\cos x} + -1\right)} \]
    4. Taylor expanded in x around inf 0.5

      \[\leadsto 1 + \color{blue}{\frac{\frac{\sin x}{\cos x} - \sin x}{x}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.2

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

Reproduce

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