Average Error: 31.6 → 0.1
Time: 11.5s
Precision: binary64
\[\frac{x - \sin x}{x - \tan x} \]
\[\begin{array}{l} \mathbf{if}\;x \leq -2.594104887854674:\\ \;\;\;\;\begin{array}{l} t_0 := x \cdot \cos x\\ t_1 := {\sin x}^{2}\\ t_2 := {\cos x}^{2}\\ \left(1 + \left(\frac{t_1}{\left(x \cdot x\right) \cdot t_2} + \frac{{\left(\frac{\sin x}{\cos x}\right)}^{3}}{{x}^{3}}\right)\right) + \left(\frac{\sin x}{t_0} - \left(\left(\frac{\sin x}{x} + \frac{t_1}{x \cdot t_0}\right) + \frac{{\sin x}^{3}}{t_2 \cdot {x}^{3}}\right)\right) \end{array}\\ \mathbf{elif}\;x \leq 0.09629485008899653:\\ \;\;\;\;\mathsf{fma}\left(0.225, x \cdot x, \mathsf{fma}\left({x}^{4}, -0.009642857142857142, 0.00024107142857142857 \cdot {x}^{6}\right)\right) - 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{x - \tan x}{x - \sin x}}\\ \end{array} \]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
\mathbf{if}\;x \leq -2.594104887854674:\\
\;\;\;\;\begin{array}{l}
t_0 := x \cdot \cos x\\
t_1 := {\sin x}^{2}\\
t_2 := {\cos x}^{2}\\
\left(1 + \left(\frac{t_1}{\left(x \cdot x\right) \cdot t_2} + \frac{{\left(\frac{\sin x}{\cos x}\right)}^{3}}{{x}^{3}}\right)\right) + \left(\frac{\sin x}{t_0} - \left(\left(\frac{\sin x}{x} + \frac{t_1}{x \cdot t_0}\right) + \frac{{\sin x}^{3}}{t_2 \cdot {x}^{3}}\right)\right)
\end{array}\\

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

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


\end{array}
(FPCore (x) :precision binary64 (/ (- x (sin x)) (- x (tan x))))
(FPCore (x)
 :precision binary64
 (if (<= x -2.594104887854674)
   (let* ((t_0 (* x (cos x))) (t_1 (pow (sin x) 2.0)) (t_2 (pow (cos x) 2.0)))
     (+
      (+
       1.0
       (+
        (/ t_1 (* (* x x) t_2))
        (/ (pow (/ (sin x) (cos x)) 3.0) (pow x 3.0))))
      (-
       (/ (sin x) t_0)
       (+
        (+ (/ (sin x) x) (/ t_1 (* x t_0)))
        (/ (pow (sin x) 3.0) (* t_2 (pow x 3.0)))))))
   (if (<= x 0.09629485008899653)
     (-
      (fma
       0.225
       (* x x)
       (fma
        (pow x 4.0)
        -0.009642857142857142
        (* 0.00024107142857142857 (pow x 6.0))))
      0.5)
     (/ 1.0 (/ (- x (tan x)) (- x (sin x)))))))
double code(double x) {
	return (x - sin(x)) / (x - tan(x));
}
double code(double x) {
	double tmp;
	if (x <= -2.594104887854674) {
		double t_0_1 = x * cos(x);
		double t_1_2 = pow(sin(x), 2.0);
		double t_2_3 = pow(cos(x), 2.0);
		tmp = (1.0 + ((t_1_2 / ((x * x) * t_2_3)) + (pow((sin(x) / cos(x)), 3.0) / pow(x, 3.0)))) + ((sin(x) / t_0_1) - (((sin(x) / x) + (t_1_2 / (x * t_0_1))) + (pow(sin(x), 3.0) / (t_2_3 * pow(x, 3.0)))));
	} else if (x <= 0.09629485008899653) {
		tmp = fma(0.225, (x * x), fma(pow(x, 4.0), -0.009642857142857142, (0.00024107142857142857 * pow(x, 6.0)))) - 0.5;
	} else {
		tmp = 1.0 / ((x - tan(x)) / (x - sin(x)));
	}
	return tmp;
}

Error

Bits error versus x

Derivation

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

    1. Initial program 0.0

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

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

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

    if -2.594104887854674 < x < 0.0962948500889965336

    1. Initial program 62.7

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.225, x \cdot x, 0.00024107142857142857 \cdot {x}^{6}\right) - \mathsf{fma}\left(0.009642857142857142, {x}^{4}, 0.5\right)} \]
    4. Applied fma-udef_binary640.1

      \[\leadsto \mathsf{fma}\left(0.225, x \cdot x, 0.00024107142857142857 \cdot {x}^{6}\right) - \color{blue}{\left(0.009642857142857142 \cdot {x}^{4} + 0.5\right)} \]
    5. Applied associate--r+_binary640.1

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

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

    if 0.0962948500889965336 < x

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Applied clear-num_binary640.0

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

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

Reproduce

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