Average Error: 31.7 → 0.0
Time: 12.7s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.03558841906319749198717161675631359685212 \lor \neg \left(x \le 0.0407911260620836546575418424254166893661\right):\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{fma}\left(\frac{9}{40} \cdot e^{\frac{-1}{2}}, {x}^{2}, \left(e^{\frac{-1}{2}} + \frac{351}{22400} \cdot \left(e^{\frac{-1}{2}} \cdot {x}^{4}\right)\right) - 1\right)\right)\\ \end{array}\]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
\mathbf{if}\;x \le -0.03558841906319749198717161675631359685212 \lor \neg \left(x \le 0.0407911260620836546575418424254166893661\right):\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{fma}\left(\frac{9}{40} \cdot e^{\frac{-1}{2}}, {x}^{2}, \left(e^{\frac{-1}{2}} + \frac{351}{22400} \cdot \left(e^{\frac{-1}{2}} \cdot {x}^{4}\right)\right) - 1\right)\right)\\

\end{array}
double f(double x) {
        double r24905 = x;
        double r24906 = sin(r24905);
        double r24907 = r24905 - r24906;
        double r24908 = tan(r24905);
        double r24909 = r24905 - r24908;
        double r24910 = r24907 / r24909;
        return r24910;
}

double f(double x) {
        double r24911 = x;
        double r24912 = -0.03558841906319749;
        bool r24913 = r24911 <= r24912;
        double r24914 = 0.040791126062083655;
        bool r24915 = r24911 <= r24914;
        double r24916 = !r24915;
        bool r24917 = r24913 || r24916;
        double r24918 = tan(r24911);
        double r24919 = r24911 - r24918;
        double r24920 = r24911 / r24919;
        double r24921 = sin(r24911);
        double r24922 = r24921 / r24919;
        double r24923 = r24920 - r24922;
        double r24924 = expm1(r24923);
        double r24925 = log1p(r24924);
        double r24926 = 0.225;
        double r24927 = -0.5;
        double r24928 = exp(r24927);
        double r24929 = r24926 * r24928;
        double r24930 = 2.0;
        double r24931 = pow(r24911, r24930);
        double r24932 = 0.015669642857142858;
        double r24933 = 4.0;
        double r24934 = pow(r24911, r24933);
        double r24935 = r24928 * r24934;
        double r24936 = r24932 * r24935;
        double r24937 = r24928 + r24936;
        double r24938 = 1.0;
        double r24939 = r24937 - r24938;
        double r24940 = fma(r24929, r24931, r24939);
        double r24941 = log1p(r24940);
        double r24942 = r24917 ? r24925 : r24941;
        return r24942;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.03558841906319749 or 0.040791126062083655 < x

    1. Initial program 0.0

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

      \[\leadsto \color{blue}{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}}\]
    4. Using strategy rm
    5. Applied log1p-expm1-u0.0

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\right)\right)}\]

    if -0.03558841906319749 < x < 0.040791126062083655

    1. Initial program 63.0

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

      \[\leadsto \color{blue}{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}}\]
    4. Using strategy rm
    5. Applied log1p-expm1-u62.9

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\right)\right)}\]
    6. Taylor expanded around 0 0.0

      \[\leadsto \mathsf{log1p}\left(\color{blue}{\left(\frac{9}{40} \cdot \left(e^{\frac{-1}{2}} \cdot {x}^{2}\right) + \left(e^{\frac{-1}{2}} + \frac{351}{22400} \cdot \left(e^{\frac{-1}{2}} \cdot {x}^{4}\right)\right)\right) - 1}\right)\]
    7. Simplified0.0

      \[\leadsto \mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(\frac{9}{40} \cdot e^{\frac{-1}{2}}, {x}^{2}, \left(e^{\frac{-1}{2}} + \frac{351}{22400} \cdot \left(e^{\frac{-1}{2}} \cdot {x}^{4}\right)\right) - 1\right)}\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.03558841906319749198717161675631359685212 \lor \neg \left(x \le 0.0407911260620836546575418424254166893661\right):\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{fma}\left(\frac{9}{40} \cdot e^{\frac{-1}{2}}, {x}^{2}, \left(e^{\frac{-1}{2}} + \frac{351}{22400} \cdot \left(e^{\frac{-1}{2}} \cdot {x}^{4}\right)\right) - 1\right)\right)\\ \end{array}\]

Reproduce

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