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

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

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := {\sin x}^{3}\\
t_1 := {\sin x}^{2}\\
t_2 := {\cos x}^{2}\\
\left(\frac{\sin x}{x \cdot \cos x} + \left(1 + \left(\frac{t_0}{{\cos x}^{3} \cdot {x}^{3}} + \frac{t_1}{t_2 \cdot {x}^{2}}\right)\right)\right) - \left(\frac{t_0}{{x}^{3} \cdot t_2} + \left(\frac{t_1}{\cos x \cdot {x}^{2}} + \frac{\sin x}{x}\right)\right)
\end{array}\\


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

Error

Bits error versus x

Derivation

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

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Taylor expanded 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 around inf 0.5

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

    if -4.8895518510382754 < x < 2.6377554044873825

    1. Initial program 62.9

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Taylor expanded 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. Taylor expanded 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)} \]
    5. Simplified0.1

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

    if 2.6377554044873825 < x

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Taylor expanded 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. Recombined 3 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.889551851038275:\\ \;\;\;\;1 + \frac{\frac{\sin x}{\cos x} - \sin x}{x}\\ \mathbf{elif}\;x \leq 2.6377554044873825:\\ \;\;\;\;\mathsf{fma}\left(0.225, x \cdot x, \mathsf{fma}\left(0.00024107142857142857, {x}^{6}, \mathsf{fma}\left({x}^{4}, -0.009642857142857142, -0.5\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{\sin x}{x \cdot \cos 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}}{{x}^{3} \cdot {\cos x}^{2}} + \left(\frac{{\sin x}^{2}}{\cos x \cdot {x}^{2}} + \frac{\sin x}{x}\right)\right)\\ \end{array} \]

Reproduce

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