Average Error: 31.5 → 0.0
Time: 4.4m
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.03308569083367182:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.03078436997544294:\\ \;\;\;\;\mathsf{fma}\left(\left(x \cdot x\right), \left(\mathsf{fma}\left(\left(x \cdot x\right), \frac{-27}{2800}, \frac{9}{40}\right)\right), \frac{-1}{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \end{array}\]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
\mathbf{if}\;x \le -0.03308569083367182:\\
\;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\

\end{array}
double f(double x) {
        double r8135377 = x;
        double r8135378 = sin(r8135377);
        double r8135379 = r8135377 - r8135378;
        double r8135380 = tan(r8135377);
        double r8135381 = r8135377 - r8135380;
        double r8135382 = r8135379 / r8135381;
        return r8135382;
}

double f(double x) {
        double r8135383 = x;
        double r8135384 = -0.03308569083367182;
        bool r8135385 = r8135383 <= r8135384;
        double r8135386 = tan(r8135383);
        double r8135387 = r8135383 - r8135386;
        double r8135388 = r8135383 / r8135387;
        double r8135389 = sin(r8135383);
        double r8135390 = r8135389 / r8135387;
        double r8135391 = r8135388 - r8135390;
        double r8135392 = 0.03078436997544294;
        bool r8135393 = r8135383 <= r8135392;
        double r8135394 = r8135383 * r8135383;
        double r8135395 = -0.009642857142857142;
        double r8135396 = 0.225;
        double r8135397 = fma(r8135394, r8135395, r8135396);
        double r8135398 = -0.5;
        double r8135399 = fma(r8135394, r8135397, r8135398);
        double r8135400 = r8135393 ? r8135399 : r8135391;
        double r8135401 = r8135385 ? r8135391 : r8135400;
        return r8135401;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.03308569083367182 or 0.03078436997544294 < x

    1. Initial program 0.0

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

      \[\leadsto \color{blue}{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}}\]

    if -0.03308569083367182 < x < 0.03078436997544294

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

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

Reproduce

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