Average Error: 30.7 → 0.1
Time: 33.6s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.02581010450665607:\\ \;\;\;\;\log \left(e^{\frac{x - \sin x}{x - \tan x}}\right)\\ \mathbf{elif}\;x \le 2.433269626118002:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(\frac{9}{40} - \left(x \cdot x\right) \cdot \frac{27}{2800}\right) - \frac{1}{2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\frac{\sin x}{x}}{x}, \frac{\sin x}{\cos x \cdot \cos x}, \frac{\sin x}{\cos x \cdot x} - \mathsf{fma}\left(\frac{\frac{\sin x}{x}}{x}, \frac{\sin x}{\cos x}, \frac{\sin x}{x}\right)\right) + 1\\ \end{array}\]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
\mathbf{if}\;x \le -0.02581010450665607:\\
\;\;\;\;\log \left(e^{\frac{x - \sin x}{x - \tan x}}\right)\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{\sin x}{x}}{x}, \frac{\sin x}{\cos x \cdot \cos x}, \frac{\sin x}{\cos x \cdot x} - \mathsf{fma}\left(\frac{\frac{\sin x}{x}}{x}, \frac{\sin x}{\cos x}, \frac{\sin x}{x}\right)\right) + 1\\

\end{array}
double f(double x) {
        double r690249 = x;
        double r690250 = sin(r690249);
        double r690251 = r690249 - r690250;
        double r690252 = tan(r690249);
        double r690253 = r690249 - r690252;
        double r690254 = r690251 / r690253;
        return r690254;
}

double f(double x) {
        double r690255 = x;
        double r690256 = -0.02581010450665607;
        bool r690257 = r690255 <= r690256;
        double r690258 = sin(r690255);
        double r690259 = r690255 - r690258;
        double r690260 = tan(r690255);
        double r690261 = r690255 - r690260;
        double r690262 = r690259 / r690261;
        double r690263 = exp(r690262);
        double r690264 = log(r690263);
        double r690265 = 2.433269626118002;
        bool r690266 = r690255 <= r690265;
        double r690267 = r690255 * r690255;
        double r690268 = 0.225;
        double r690269 = 0.009642857142857142;
        double r690270 = r690267 * r690269;
        double r690271 = r690268 - r690270;
        double r690272 = r690267 * r690271;
        double r690273 = 0.5;
        double r690274 = r690272 - r690273;
        double r690275 = r690258 / r690255;
        double r690276 = r690275 / r690255;
        double r690277 = cos(r690255);
        double r690278 = r690277 * r690277;
        double r690279 = r690258 / r690278;
        double r690280 = r690277 * r690255;
        double r690281 = r690258 / r690280;
        double r690282 = r690258 / r690277;
        double r690283 = fma(r690276, r690282, r690275);
        double r690284 = r690281 - r690283;
        double r690285 = fma(r690276, r690279, r690284);
        double r690286 = 1.0;
        double r690287 = r690285 + r690286;
        double r690288 = r690266 ? r690274 : r690287;
        double r690289 = r690257 ? r690264 : r690288;
        return r690289;
}

Error

Bits error versus x

Derivation

  1. Split input into 3 regimes
  2. if x < -0.02581010450665607

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Using strategy rm
    3. Applied add-log-exp0.1

      \[\leadsto \color{blue}{\log \left(e^{\frac{x - \sin x}{x - \tan x}}\right)}\]

    if -0.02581010450665607 < x < 2.433269626118002

    1. Initial program 62.6

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Taylor expanded around 0 0.1

      \[\leadsto \color{blue}{\frac{9}{40} \cdot {x}^{2} - \left(\frac{27}{2800} \cdot {x}^{4} + \frac{1}{2}\right)}\]
    3. Simplified0.1

      \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \left(\frac{9}{40} - \frac{27}{2800} \cdot \left(x \cdot x\right)\right) - \frac{1}{2}}\]

    if 2.433269626118002 < x

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Taylor expanded around inf 0.3

      \[\leadsto \color{blue}{\left(1 + \left(\frac{{\left(\sin x\right)}^{2}}{{\left(\cos x\right)}^{2} \cdot {x}^{2}} + \frac{\sin x}{\cos x \cdot x}\right)\right) - \left(\frac{\sin x}{x} + \frac{{\left(\sin x\right)}^{2}}{\cos x \cdot {x}^{2}}\right)}\]
    3. Simplified0.3

      \[\leadsto \color{blue}{1 + \mathsf{fma}\left(\frac{\frac{\sin x}{x}}{x}, \frac{\sin x}{\cos x \cdot \cos x}, \frac{\sin x}{x \cdot \cos x} - \mathsf{fma}\left(\frac{\frac{\sin x}{x}}{x}, \frac{\sin x}{\cos x}, \frac{\sin x}{x}\right)\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.02581010450665607:\\ \;\;\;\;\log \left(e^{\frac{x - \sin x}{x - \tan x}}\right)\\ \mathbf{elif}\;x \le 2.433269626118002:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(\frac{9}{40} - \left(x \cdot x\right) \cdot \frac{27}{2800}\right) - \frac{1}{2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\frac{\sin x}{x}}{x}, \frac{\sin x}{\cos x \cdot \cos x}, \frac{\sin x}{\cos x \cdot x} - \mathsf{fma}\left(\frac{\frac{\sin x}{x}}{x}, \frac{\sin x}{\cos x}, \frac{\sin x}{x}\right)\right) + 1\\ \end{array}\]

Reproduce

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