Average Error: 31.5 → 0.0
Time: 32.8s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.02464141707269403:\\ \;\;\;\;\mathsf{expm1}\left(\left(\mathsf{log1p}\left(\left(\frac{x - \sin x}{x - \tan x}\right)\right)\right)\right)\\ \mathbf{elif}\;x \le 0.02782498439406133:\\ \;\;\;\;\frac{-27}{2800} \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) + \mathsf{fma}\left(\frac{9}{40}, \left(x \cdot x\right), \frac{-1}{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(\left(\mathsf{log1p}\left(\left(\frac{x - \sin x}{x - \tan x}\right)\right)\right)\right)\\ \end{array}\]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
\mathbf{if}\;x \le -0.02464141707269403:\\
\;\;\;\;\mathsf{expm1}\left(\left(\mathsf{log1p}\left(\left(\frac{x - \sin x}{x - \tan x}\right)\right)\right)\right)\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\left(\mathsf{log1p}\left(\left(\frac{x - \sin x}{x - \tan x}\right)\right)\right)\right)\\

\end{array}
double f(double x) {
        double r635897 = x;
        double r635898 = sin(r635897);
        double r635899 = r635897 - r635898;
        double r635900 = tan(r635897);
        double r635901 = r635897 - r635900;
        double r635902 = r635899 / r635901;
        return r635902;
}

double f(double x) {
        double r635903 = x;
        double r635904 = -0.02464141707269403;
        bool r635905 = r635903 <= r635904;
        double r635906 = sin(r635903);
        double r635907 = r635903 - r635906;
        double r635908 = tan(r635903);
        double r635909 = r635903 - r635908;
        double r635910 = r635907 / r635909;
        double r635911 = log1p(r635910);
        double r635912 = expm1(r635911);
        double r635913 = 0.02782498439406133;
        bool r635914 = r635903 <= r635913;
        double r635915 = -0.009642857142857142;
        double r635916 = r635903 * r635903;
        double r635917 = r635916 * r635916;
        double r635918 = r635915 * r635917;
        double r635919 = 0.225;
        double r635920 = -0.5;
        double r635921 = fma(r635919, r635916, r635920);
        double r635922 = r635918 + r635921;
        double r635923 = r635914 ? r635922 : r635912;
        double r635924 = r635905 ? r635912 : r635923;
        return r635924;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.02464141707269403 or 0.02782498439406133 < x

    1. Initial program 0.1

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Using strategy rm
    3. Applied expm1-log1p-u0.1

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\left(\mathsf{log1p}\left(\left(\frac{x - \sin x}{x - \tan x}\right)\right)\right)\right)}\]
    4. Using strategy rm
    5. Applied div-inv0.1

      \[\leadsto \mathsf{expm1}\left(\left(\mathsf{log1p}\left(\color{blue}{\left(\left(x - \sin x\right) \cdot \frac{1}{x - \tan x}\right)}\right)\right)\right)\]
    6. Using strategy rm
    7. Applied expm1-log1p-u0.1

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

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

    if -0.02464141707269403 < x < 0.02782498439406133

    1. Initial program 62.9

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Using strategy rm
    3. Applied expm1-log1p-u62.9

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\left(\mathsf{log1p}\left(\left(\frac{x - \sin x}{x - \tan x}\right)\right)\right)\right)}\]
    4. Using strategy rm
    5. Applied div-inv62.9

      \[\leadsto \mathsf{expm1}\left(\left(\mathsf{log1p}\left(\color{blue}{\left(\left(x - \sin x\right) \cdot \frac{1}{x - \tan x}\right)}\right)\right)\right)\]
    6. 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)}\]
    7. Simplified0.0

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

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

Reproduce

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