Average Error: 30.9 → 0.0
Time: 10.5s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.028744253704368783:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.0319715048145489053:\\ \;\;\;\;\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}{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.028744253704368783:\\
\;\;\;\;\frac{x - \sin x}{x - \tan x}\\

\mathbf{elif}\;x \le 0.0319715048145489053:\\
\;\;\;\;\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}{x - \tan x} - \frac{\sin x}{x - \tan x}\\

\end{array}
double f(double x) {
        double r14886 = x;
        double r14887 = sin(r14886);
        double r14888 = r14886 - r14887;
        double r14889 = tan(r14886);
        double r14890 = r14886 - r14889;
        double r14891 = r14888 / r14890;
        return r14891;
}

double f(double x) {
        double r14892 = x;
        double r14893 = -0.028744253704368783;
        bool r14894 = r14892 <= r14893;
        double r14895 = sin(r14892);
        double r14896 = r14892 - r14895;
        double r14897 = tan(r14892);
        double r14898 = r14892 - r14897;
        double r14899 = r14896 / r14898;
        double r14900 = 0.031971504814548905;
        bool r14901 = r14892 <= r14900;
        double r14902 = 0.225;
        double r14903 = 2.0;
        double r14904 = pow(r14892, r14903);
        double r14905 = 0.009642857142857142;
        double r14906 = 4.0;
        double r14907 = pow(r14892, r14906);
        double r14908 = 0.5;
        double r14909 = fma(r14905, r14907, r14908);
        double r14910 = -r14909;
        double r14911 = fma(r14902, r14904, r14910);
        double r14912 = r14892 / r14898;
        double r14913 = r14895 / r14898;
        double r14914 = r14912 - r14913;
        double r14915 = r14901 ? r14911 : r14914;
        double r14916 = r14894 ? r14899 : r14915;
        return r14916;
}

Error

Bits error versus x

Derivation

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

    1. Initial program 0.1

      \[\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.1

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

    if -0.028744253704368783 < x < 0.031971504814548905

    1. Initial program 63.1

      \[\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.031971504814548905 < x

    1. Initial program 0.0

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

      \[\leadsto \color{blue}{\frac{x}{x - \tan x} - \frac{\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.028744253704368783:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.0319715048145489053:\\ \;\;\;\;\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}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \end{array}\]

Reproduce

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