Average Error: 32.1 → 0.0
Time: 12.7s
Precision: binary64
\[\frac{x - \sin x}{x - \tan x} \]
\[\begin{array}{l} t_0 := \frac{x - \sin x}{x - \tan x}\\ \mathbf{if}\;x \leq -0.004877358576892519:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.005389730405536012:\\ \;\;\;\;\mathsf{fma}\left(0.225, x \cdot x, -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{t_0}\right)\\ \end{array} \]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
t_0 := \frac{x - \sin x}{x - \tan x}\\
\mathbf{if}\;x \leq -0.004877358576892519:\\
\;\;\;\;t_0\\

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

\mathbf{else}:\\
\;\;\;\;\log \left(e^{t_0}\right)\\


\end{array}
(FPCore (x) :precision binary64 (/ (- x (sin x)) (- x (tan x))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (/ (- x (sin x)) (- x (tan x)))))
   (if (<= x -0.004877358576892519)
     t_0
     (if (<= x 0.005389730405536012)
       (fma 0.225 (* x x) -0.5)
       (log (exp t_0))))))
double code(double x) {
	return (x - sin(x)) / (x - tan(x));
}
double code(double x) {
	double t_0 = (x - sin(x)) / (x - tan(x));
	double tmp;
	if (x <= -0.004877358576892519) {
		tmp = t_0;
	} else if (x <= 0.005389730405536012) {
		tmp = fma(0.225, (x * x), -0.5);
	} else {
		tmp = log(exp(t_0));
	}
	return tmp;
}

Error

Bits error versus x

Derivation

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

    1. Initial program 0.1

      \[\frac{x - \sin x}{x - \tan x} \]

    if -0.00487735857689251904 < x < 0.0053897304055360116

    1. Initial program 63.4

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

      \[\leadsto \color{blue}{0.225 \cdot {x}^{2} - 0.5} \]
    3. Simplified0.0

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

    if 0.0053897304055360116 < x

    1. Initial program 0.1

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Applied add-log-exp_binary640.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.004877358576892519:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{elif}\;x \leq 0.005389730405536012:\\ \;\;\;\;\mathsf{fma}\left(0.225, x \cdot x, -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{\frac{x - \sin x}{x - \tan x}}\right)\\ \end{array} \]

Reproduce

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