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

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

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

\end{array}
double f(double x) {
        double r1027428 = x;
        double r1027429 = sin(r1027428);
        double r1027430 = r1027428 - r1027429;
        double r1027431 = tan(r1027428);
        double r1027432 = r1027428 - r1027431;
        double r1027433 = r1027430 / r1027432;
        return r1027433;
}

double f(double x) {
        double r1027434 = x;
        double r1027435 = -0.02697179057437607;
        bool r1027436 = r1027434 <= r1027435;
        double r1027437 = tan(r1027434);
        double r1027438 = r1027434 - r1027437;
        double r1027439 = r1027434 / r1027438;
        double r1027440 = sin(r1027434);
        double r1027441 = r1027440 / r1027438;
        double r1027442 = r1027439 - r1027441;
        double r1027443 = log1p(r1027442);
        double r1027444 = expm1(r1027443);
        double r1027445 = 0.029925645760154832;
        bool r1027446 = r1027434 <= r1027445;
        double r1027447 = r1027434 * r1027434;
        double r1027448 = 0.225;
        double r1027449 = -0.5;
        double r1027450 = fma(r1027447, r1027448, r1027449);
        double r1027451 = r1027447 * r1027447;
        double r1027452 = -0.009642857142857142;
        double r1027453 = r1027451 * r1027452;
        double r1027454 = r1027450 + r1027453;
        double r1027455 = r1027446 ? r1027454 : r1027444;
        double r1027456 = r1027436 ? r1027444 : r1027455;
        return r1027456;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.02697179057437607 or 0.029925645760154832 < x

    1. Initial program 0.1

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

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

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

    if -0.02697179057437607 < x < 0.029925645760154832

    1. Initial program 62.7

      \[\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(x \cdot x, \frac{9}{40}, \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.02697179057437607:\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\right)\right)\\ \mathbf{elif}\;x \le 0.029925645760154832:\\ \;\;\;\;\mathsf{fma}\left(x \cdot x, \frac{9}{40}, \frac{-1}{2}\right) + \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \frac{-27}{2800}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\right)\right)\\ \end{array}\]

Reproduce

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