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

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

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


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

Error

Bits error versus x

Derivation

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

    1. Initial program 0.0

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

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

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

    if -2.76979686120281832 < x < 0.0832521021405943223

    1. Initial program 63.0

      \[\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. 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)} \]
    5. Simplified0.1

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

    if 0.0832521021405943223 < x

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Applied egg-rr0.0

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

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

Reproduce

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