Average Error: 31.7 → 0.0
Time: 11.0s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.0290170878265866537 \lor \neg \left(x \le 0.0311971006789354723\right):\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \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.0290170878265866537 \lor \neg \left(x \le 0.0311971006789354723\right):\\
\;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\

\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 r14842 = x;
        double r14843 = sin(r14842);
        double r14844 = r14842 - r14843;
        double r14845 = tan(r14842);
        double r14846 = r14842 - r14845;
        double r14847 = r14844 / r14846;
        return r14847;
}

double f(double x) {
        double r14848 = x;
        double r14849 = -0.029017087826586654;
        bool r14850 = r14848 <= r14849;
        double r14851 = 0.031197100678935472;
        bool r14852 = r14848 <= r14851;
        double r14853 = !r14852;
        bool r14854 = r14850 || r14853;
        double r14855 = tan(r14848);
        double r14856 = r14848 - r14855;
        double r14857 = r14848 / r14856;
        double r14858 = sin(r14848);
        double r14859 = r14858 / r14856;
        double r14860 = r14857 - r14859;
        double r14861 = 0.225;
        double r14862 = 2.0;
        double r14863 = pow(r14848, r14862);
        double r14864 = 0.009642857142857142;
        double r14865 = 4.0;
        double r14866 = pow(r14848, r14865);
        double r14867 = 0.5;
        double r14868 = fma(r14864, r14866, r14867);
        double r14869 = -r14868;
        double r14870 = fma(r14861, r14863, r14869);
        double r14871 = r14854 ? r14860 : r14870;
        return r14871;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.029017087826586654 or 0.031197100678935472 < 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.029017087826586654 < x < 0.031197100678935472

    1. Initial program 63.2

      \[\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.0290170878265866537 \lor \neg \left(x \le 0.0311971006789354723\right):\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \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 2020083 +o rules:numerics
(FPCore (x)
  :name "sintan (problem 3.4.5)"
  :precision binary64
  (/ (- x (sin x)) (- x (tan x))))