Average Error: 31.2 → 0.0
Time: 39.0s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.02687365489421502:\\ \;\;\;\;\mathsf{log1p}\left(\left(\mathsf{expm1}\left(\left(\frac{x - \sin x}{x - \tan x}\right)\right)\right)\right)\\ \mathbf{elif}\;x \le 0.026232161789625133:\\ \;\;\;\;\mathsf{fma}\left(\left(x \cdot x\right), \frac{9}{40}, \left(\mathsf{fma}\left(\frac{-27}{2800}, \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right), \frac{-1}{2}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(\left(\mathsf{expm1}\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.02687365489421502:\\
\;\;\;\;\mathsf{log1p}\left(\left(\mathsf{expm1}\left(\left(\frac{x - \sin x}{x - \tan x}\right)\right)\right)\right)\\

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

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

\end{array}
double f(double x) {
        double r887878 = x;
        double r887879 = sin(r887878);
        double r887880 = r887878 - r887879;
        double r887881 = tan(r887878);
        double r887882 = r887878 - r887881;
        double r887883 = r887880 / r887882;
        return r887883;
}

double f(double x) {
        double r887884 = x;
        double r887885 = -0.02687365489421502;
        bool r887886 = r887884 <= r887885;
        double r887887 = sin(r887884);
        double r887888 = r887884 - r887887;
        double r887889 = tan(r887884);
        double r887890 = r887884 - r887889;
        double r887891 = r887888 / r887890;
        double r887892 = expm1(r887891);
        double r887893 = log1p(r887892);
        double r887894 = 0.026232161789625133;
        bool r887895 = r887884 <= r887894;
        double r887896 = r887884 * r887884;
        double r887897 = 0.225;
        double r887898 = -0.009642857142857142;
        double r887899 = r887896 * r887896;
        double r887900 = -0.5;
        double r887901 = fma(r887898, r887899, r887900);
        double r887902 = fma(r887896, r887897, r887901);
        double r887903 = r887895 ? r887902 : r887893;
        double r887904 = r887886 ? r887893 : r887903;
        return r887904;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.02687365489421502 or 0.026232161789625133 < x

    1. Initial program 0.0

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

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

    if -0.02687365489421502 < x < 0.026232161789625133

    1. Initial program 62.8

      \[\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(\left(x \cdot x\right), \frac{9}{40}, \left(\mathsf{fma}\left(\frac{-27}{2800}, \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right), \frac{-1}{2}\right)\right)\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

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

Reproduce

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