Average Error: 32.1 → 0.0
Time: 10.5s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.02951458613282759504969909869487310061231:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.02672696280496188875330787482198502402753:\\ \;\;\;\;\mathsf{fma}\left(\frac{9}{40}, {x}^{2}, -\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \end{array}\]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
\mathbf{if}\;x \le -0.02951458613282759504969909869487310061231:\\
\;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\

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

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

\end{array}
double f(double x) {
        double r14891 = x;
        double r14892 = sin(r14891);
        double r14893 = r14891 - r14892;
        double r14894 = tan(r14891);
        double r14895 = r14891 - r14894;
        double r14896 = r14893 / r14895;
        return r14896;
}

double f(double x) {
        double r14897 = x;
        double r14898 = -0.029514586132827595;
        bool r14899 = r14897 <= r14898;
        double r14900 = tan(r14897);
        double r14901 = r14897 - r14900;
        double r14902 = r14897 / r14901;
        double r14903 = sin(r14897);
        double r14904 = r14903 / r14901;
        double r14905 = r14902 - r14904;
        double r14906 = 0.02672696280496189;
        bool r14907 = r14897 <= r14906;
        double r14908 = 0.225;
        double r14909 = 2.0;
        double r14910 = pow(r14897, r14909);
        double r14911 = 0.009642857142857142;
        double r14912 = 4.0;
        double r14913 = pow(r14897, r14912);
        double r14914 = 0.5;
        double r14915 = fma(r14911, r14913, r14914);
        double r14916 = -r14915;
        double r14917 = fma(r14908, r14910, r14916);
        double r14918 = r14897 - r14903;
        double r14919 = r14918 / r14901;
        double r14920 = r14907 ? r14917 : r14919;
        double r14921 = r14899 ? r14905 : r14920;
        return r14921;
}

Error

Bits error versus x

Derivation

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

    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.029514586132827595 < x < 0.02672696280496189

    1. Initial program 63.3

      \[\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)}\]

    if 0.02672696280496189 < 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 sub-div0.0

      \[\leadsto \color{blue}{\frac{x - \sin x}{x - \tan x}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.0

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

Reproduce

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