Average Error: 31.1 → 0.1
Time: 1.9m
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.03414424847811019236853979919033008627594:\\ \;\;\;\;\mathsf{fma}\left(\frac{\sin x}{x - \tan x}, -1, \frac{\sin x}{x - \tan x}\right) + \left(\frac{1}{x - \tan x} \cdot x - \frac{\sin x}{x - \tan x}\right)\\ \mathbf{elif}\;x \le 1.58452353472773377340843126148683950305:\\ \;\;\;\;\mathsf{fma}\left(\frac{9}{40}, x \cdot x, \mathsf{fma}\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right), \frac{-27}{2800}, \frac{-1}{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\sqrt{\frac{x}{x - \tan x}}, \sqrt{\frac{x}{x - \tan x}}, \frac{-\sin x}{x - \tan x}\right)\\ \end{array}\]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
\mathbf{if}\;x \le -0.03414424847811019236853979919033008627594:\\
\;\;\;\;\mathsf{fma}\left(\frac{\sin x}{x - \tan x}, -1, \frac{\sin x}{x - \tan x}\right) + \left(\frac{1}{x - \tan x} \cdot x - \frac{\sin x}{x - \tan x}\right)\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt{\frac{x}{x - \tan x}}, \sqrt{\frac{x}{x - \tan x}}, \frac{-\sin x}{x - \tan x}\right)\\

\end{array}
double f(double x) {
        double r817426 = x;
        double r817427 = sin(r817426);
        double r817428 = r817426 - r817427;
        double r817429 = tan(r817426);
        double r817430 = r817426 - r817429;
        double r817431 = r817428 / r817430;
        return r817431;
}

double f(double x) {
        double r817432 = x;
        double r817433 = -0.03414424847811019;
        bool r817434 = r817432 <= r817433;
        double r817435 = sin(r817432);
        double r817436 = tan(r817432);
        double r817437 = r817432 - r817436;
        double r817438 = r817435 / r817437;
        double r817439 = -1.0;
        double r817440 = fma(r817438, r817439, r817438);
        double r817441 = 1.0;
        double r817442 = r817441 / r817437;
        double r817443 = r817442 * r817432;
        double r817444 = r817443 - r817438;
        double r817445 = r817440 + r817444;
        double r817446 = 1.5845235347277338;
        bool r817447 = r817432 <= r817446;
        double r817448 = 0.225;
        double r817449 = r817432 * r817432;
        double r817450 = r817449 * r817449;
        double r817451 = -0.009642857142857142;
        double r817452 = -0.5;
        double r817453 = fma(r817450, r817451, r817452);
        double r817454 = fma(r817448, r817449, r817453);
        double r817455 = r817432 / r817437;
        double r817456 = sqrt(r817455);
        double r817457 = -r817435;
        double r817458 = r817457 / r817437;
        double r817459 = fma(r817456, r817456, r817458);
        double r817460 = r817447 ? r817454 : r817459;
        double r817461 = r817434 ? r817445 : r817460;
        return r817461;
}

Error

Bits error versus x

Derivation

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

    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}}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt0.1

      \[\leadsto \frac{x}{x - \tan x} - \color{blue}{\left(\sqrt[3]{\frac{\sin x}{x - \tan x}} \cdot \sqrt[3]{\frac{\sin x}{x - \tan x}}\right) \cdot \sqrt[3]{\frac{\sin x}{x - \tan x}}}\]
    6. Applied div-inv0.2

      \[\leadsto \color{blue}{x \cdot \frac{1}{x - \tan x}} - \left(\sqrt[3]{\frac{\sin x}{x - \tan x}} \cdot \sqrt[3]{\frac{\sin x}{x - \tan x}}\right) \cdot \sqrt[3]{\frac{\sin x}{x - \tan x}}\]
    7. Applied prod-diff0.2

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{1}{x - \tan x}, -\sqrt[3]{\frac{\sin x}{x - \tan x}} \cdot \left(\sqrt[3]{\frac{\sin x}{x - \tan x}} \cdot \sqrt[3]{\frac{\sin x}{x - \tan x}}\right)\right) + \mathsf{fma}\left(-\sqrt[3]{\frac{\sin x}{x - \tan x}}, \sqrt[3]{\frac{\sin x}{x - \tan x}} \cdot \sqrt[3]{\frac{\sin x}{x - \tan x}}, \sqrt[3]{\frac{\sin x}{x - \tan x}} \cdot \left(\sqrt[3]{\frac{\sin x}{x - \tan x}} \cdot \sqrt[3]{\frac{\sin x}{x - \tan x}}\right)\right)}\]
    8. Simplified0.2

      \[\leadsto \color{blue}{\left(x \cdot \frac{1}{x - \tan x} - \frac{\sin x}{x - \tan x}\right)} + \mathsf{fma}\left(-\sqrt[3]{\frac{\sin x}{x - \tan x}}, \sqrt[3]{\frac{\sin x}{x - \tan x}} \cdot \sqrt[3]{\frac{\sin x}{x - \tan x}}, \sqrt[3]{\frac{\sin x}{x - \tan x}} \cdot \left(\sqrt[3]{\frac{\sin x}{x - \tan x}} \cdot \sqrt[3]{\frac{\sin x}{x - \tan x}}\right)\right)\]
    9. Simplified0.2

      \[\leadsto \left(x \cdot \frac{1}{x - \tan x} - \frac{\sin x}{x - \tan x}\right) + \color{blue}{\mathsf{fma}\left(\frac{\sin x}{x - \tan x}, -1, \frac{\sin x}{x - \tan x}\right)}\]

    if -0.03414424847811019 < x < 1.5845235347277338

    1. Initial program 63.0

      \[\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}{\mathsf{fma}\left(\frac{9}{40}, x \cdot x, \mathsf{fma}\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right), \frac{-27}{2800}, \frac{-1}{2}\right)\right)}\]

    if 1.5845235347277338 < 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}}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt0.0

      \[\leadsto \color{blue}{\sqrt{\frac{x}{x - \tan x}} \cdot \sqrt{\frac{x}{x - \tan x}}} - \frac{\sin x}{x - \tan x}\]
    6. Applied fma-neg0.0

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

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

Reproduce

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