Average Error: 31.5 → 0.0
Time: 9.7s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.02379170798130310002238552158360107569024 \lor \neg \left(x \le 0.03071147796493317594368477330135647207499\right):\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x - \sin x}{x - \tan x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{9}{40}, {x}^{2}, -\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right)\\ \end{array}\]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
\mathbf{if}\;x \le -0.02379170798130310002238552158360107569024 \lor \neg \left(x \le 0.03071147796493317594368477330135647207499\right):\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x - \sin x}{x - \tan x}\right)\right)\\

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

\end{array}
double f(double x) {
        double r12307 = x;
        double r12308 = sin(r12307);
        double r12309 = r12307 - r12308;
        double r12310 = tan(r12307);
        double r12311 = r12307 - r12310;
        double r12312 = r12309 / r12311;
        return r12312;
}

double f(double x) {
        double r12313 = x;
        double r12314 = -0.0237917079813031;
        bool r12315 = r12313 <= r12314;
        double r12316 = 0.030711477964933176;
        bool r12317 = r12313 <= r12316;
        double r12318 = !r12317;
        bool r12319 = r12315 || r12318;
        double r12320 = sin(r12313);
        double r12321 = r12313 - r12320;
        double r12322 = tan(r12313);
        double r12323 = r12313 - r12322;
        double r12324 = r12321 / r12323;
        double r12325 = expm1(r12324);
        double r12326 = log1p(r12325);
        double r12327 = 0.225;
        double r12328 = 2.0;
        double r12329 = pow(r12313, r12328);
        double r12330 = 0.009642857142857142;
        double r12331 = 4.0;
        double r12332 = pow(r12313, r12331);
        double r12333 = 0.5;
        double r12334 = fma(r12330, r12332, r12333);
        double r12335 = -r12334;
        double r12336 = fma(r12327, r12329, r12335);
        double r12337 = r12319 ? r12326 : r12336;
        return r12337;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.0237917079813031 or 0.030711477964933176 < x

    1. Initial program 0.0

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

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

    if -0.0237917079813031 < x < 0.030711477964933176

    1. Initial program 63.3

      \[\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)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.02379170798130310002238552158360107569024 \lor \neg \left(x \le 0.03071147796493317594368477330135647207499\right):\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x - \sin x}{x - \tan x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{9}{40}, {x}^{2}, -\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right)\\ \end{array}\]

Reproduce

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