Average Error: 31.5 → 0.1
Time: 11.2s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.01665811831216180982639940566514269448817:\\ \;\;\;\;\frac{1}{\frac{x}{x - \sin x} - \frac{\tan x}{x - \sin x}}\\ \mathbf{elif}\;x \le 0.01529116643609437255213467921066694543697:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\left(-\frac{9}{10} \cdot {x}^{2}\right) - \mathsf{fma}\left(\frac{513}{1400}, {x}^{4}, 2\right)}\right)\right)\\ \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 \le -0.01665811831216180982639940566514269448817:\\
\;\;\;\;\frac{1}{\frac{x}{x - \sin x} - \frac{\tan x}{x - \sin x}}\\

\mathbf{elif}\;x \le 0.01529116643609437255213467921066694543697:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\left(-\frac{9}{10} \cdot {x}^{2}\right) - \mathsf{fma}\left(\frac{513}{1400}, {x}^{4}, 2\right)}\right)\right)\\

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

\end{array}
double f(double x) {
        double r17977 = x;
        double r17978 = sin(r17977);
        double r17979 = r17977 - r17978;
        double r17980 = tan(r17977);
        double r17981 = r17977 - r17980;
        double r17982 = r17979 / r17981;
        return r17982;
}

double f(double x) {
        double r17983 = x;
        double r17984 = -0.01665811831216181;
        bool r17985 = r17983 <= r17984;
        double r17986 = 1.0;
        double r17987 = sin(r17983);
        double r17988 = r17983 - r17987;
        double r17989 = r17983 / r17988;
        double r17990 = tan(r17983);
        double r17991 = r17990 / r17988;
        double r17992 = r17989 - r17991;
        double r17993 = r17986 / r17992;
        double r17994 = 0.015291166436094373;
        bool r17995 = r17983 <= r17994;
        double r17996 = 0.9;
        double r17997 = 2.0;
        double r17998 = pow(r17983, r17997);
        double r17999 = r17996 * r17998;
        double r18000 = -r17999;
        double r18001 = 0.36642857142857144;
        double r18002 = 4.0;
        double r18003 = pow(r17983, r18002);
        double r18004 = fma(r18001, r18003, r17997);
        double r18005 = r18000 - r18004;
        double r18006 = r17986 / r18005;
        double r18007 = expm1(r18006);
        double r18008 = log1p(r18007);
        double r18009 = r17983 - r17990;
        double r18010 = r18009 / r17988;
        double r18011 = r17986 / r18010;
        double r18012 = r17995 ? r18008 : r18011;
        double r18013 = r17985 ? r17993 : r18012;
        return r18013;
}

Error

Bits error versus x

Derivation

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

    1. Initial program 0.1

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

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

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

    if -0.01665811831216181 < x < 0.015291166436094373

    1. Initial program 63.2

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Using strategy rm
    3. Applied clear-num63.2

      \[\leadsto \color{blue}{\frac{1}{\frac{x - \tan x}{x - \sin x}}}\]
    4. Taylor expanded around 0 0.0

      \[\leadsto \frac{1}{\color{blue}{-\left(\frac{9}{10} \cdot {x}^{2} + \left(\frac{513}{1400} \cdot {x}^{4} + 2\right)\right)}}\]
    5. Simplified0.0

      \[\leadsto \frac{1}{\color{blue}{\left(-\frac{9}{10} \cdot {x}^{2}\right) - \mathsf{fma}\left(\frac{513}{1400}, {x}^{4}, 2\right)}}\]
    6. Using strategy rm
    7. Applied log1p-expm1-u0.0

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\left(-\frac{9}{10} \cdot {x}^{2}\right) - \mathsf{fma}\left(\frac{513}{1400}, {x}^{4}, 2\right)}\right)\right)}\]

    if 0.015291166436094373 < x

    1. Initial program 0.1

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

      \[\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 \le -0.01665811831216180982639940566514269448817:\\ \;\;\;\;\frac{1}{\frac{x}{x - \sin x} - \frac{\tan x}{x - \sin x}}\\ \mathbf{elif}\;x \le 0.01529116643609437255213467921066694543697:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\left(-\frac{9}{10} \cdot {x}^{2}\right) - \mathsf{fma}\left(\frac{513}{1400}, {x}^{4}, 2\right)}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{x - \tan x}{x - \sin x}}\\ \end{array}\]

Reproduce

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