Average Error: 31.6 → 0.0
Time: 8.7s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.0271582929915708572:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x - \tan x}{x}, \sin x, -\left(x - \tan x\right)\right)}{\frac{x - \tan x}{x} \cdot \left(-\left(x - \tan x\right)\right)}\\ \mathbf{elif}\;x \le 0.0255064208901601384:\\ \;\;\;\;\mathsf{fma}\left(\frac{9}{40}, {x}^{2}, -\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \end{array}\]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
\mathbf{if}\;x \le -0.0271582929915708572:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x - \tan x}{x}, \sin x, -\left(x - \tan x\right)\right)}{\frac{x - \tan x}{x} \cdot \left(-\left(x - \tan x\right)\right)}\\

\mathbf{elif}\;x \le 0.0255064208901601384:\\
\;\;\;\;\mathsf{fma}\left(\frac{9}{40}, {x}^{2}, -\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right)\\

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

\end{array}
double code(double x) {
	return ((x - sin(x)) / (x - tan(x)));
}
double code(double x) {
	double VAR;
	if ((x <= -0.027158292991570857)) {
		VAR = (fma(((x - tan(x)) / x), sin(x), -(x - tan(x))) / (((x - tan(x)) / x) * -(x - tan(x))));
	} else {
		double VAR_1;
		if ((x <= 0.02550642089016014)) {
			VAR_1 = fma(0.225, pow(x, 2.0), -fma(0.009642857142857142, pow(x, 4.0), 0.5));
		} else {
			VAR_1 = ((x / (x - tan(x))) - (sin(x) / (x - tan(x))));
		}
		VAR = VAR_1;
	}
	return VAR;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

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

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Using strategy rm
    3. Applied div-sub0.1

      \[\leadsto \color{blue}{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}}\]
    4. Using strategy rm
    5. Applied frac-2neg0.1

      \[\leadsto \frac{x}{x - \tan x} - \color{blue}{\frac{-\sin x}{-\left(x - \tan x\right)}}\]
    6. Applied clear-num0.1

      \[\leadsto \color{blue}{\frac{1}{\frac{x - \tan x}{x}}} - \frac{-\sin x}{-\left(x - \tan x\right)}\]
    7. Applied frac-sub0.1

      \[\leadsto \color{blue}{\frac{1 \cdot \left(-\left(x - \tan x\right)\right) - \frac{x - \tan x}{x} \cdot \left(-\sin x\right)}{\frac{x - \tan x}{x} \cdot \left(-\left(x - \tan x\right)\right)}}\]
    8. Simplified0.1

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{x - \tan x}{x}, \sin x, -\left(x - \tan x\right)\right)}}{\frac{x - \tan x}{x} \cdot \left(-\left(x - \tan x\right)\right)}\]

    if -0.027158292991570857 < x < 0.02550642089016014

    1. Initial program 63.1

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

      \[\leadsto \color{blue}{\frac{9}{40} \cdot {x}^{2} - \left(\frac{27}{2800} \cdot {x}^{4} + \frac{1}{2}\right)}\]
    3. Simplified0.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{9}{40}, {x}^{2}, -\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right)}\]

    if 0.02550642089016014 < x

    1. Initial program 0.1

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Using strategy rm
    3. Applied div-sub0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.0271582929915708572:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x - \tan x}{x}, \sin x, -\left(x - \tan x\right)\right)}{\frac{x - \tan x}{x} \cdot \left(-\left(x - \tan x\right)\right)}\\ \mathbf{elif}\;x \le 0.0255064208901601384:\\ \;\;\;\;\mathsf{fma}\left(\frac{9}{40}, {x}^{2}, -\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \end{array}\]

Reproduce

herbie shell --seed 2020071 +o rules:numerics
(FPCore (x)
  :name "sintan (problem 3.4.5)"
  :precision binary64
  (/ (- x (sin x)) (- x (tan x))))