Average Error: 31.2 → 0.0
Time: 34.1s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.02767094041582889:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.0350085026921760009:\\ \;\;\;\;\frac{9}{40} \cdot {x}^{2} - \mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \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.02767094041582889:\\
\;\;\;\;\frac{x - \sin x}{x - \tan x}\\

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

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

\end{array}
double f(double x) {
        double r23050 = x;
        double r23051 = sin(r23050);
        double r23052 = r23050 - r23051;
        double r23053 = tan(r23050);
        double r23054 = r23050 - r23053;
        double r23055 = r23052 / r23054;
        return r23055;
}

double f(double x) {
        double r23056 = x;
        double r23057 = -0.02767094041582889;
        bool r23058 = r23056 <= r23057;
        double r23059 = sin(r23056);
        double r23060 = r23056 - r23059;
        double r23061 = tan(r23056);
        double r23062 = r23056 - r23061;
        double r23063 = r23060 / r23062;
        double r23064 = 0.035008502692176;
        bool r23065 = r23056 <= r23064;
        double r23066 = 0.225;
        double r23067 = 2.0;
        double r23068 = pow(r23056, r23067);
        double r23069 = r23066 * r23068;
        double r23070 = 0.009642857142857142;
        double r23071 = 4.0;
        double r23072 = pow(r23056, r23071);
        double r23073 = 0.5;
        double r23074 = fma(r23070, r23072, r23073);
        double r23075 = r23069 - r23074;
        double r23076 = r23056 / r23062;
        double r23077 = r23059 / r23062;
        double r23078 = r23076 - r23077;
        double r23079 = r23065 ? r23075 : r23078;
        double r23080 = r23058 ? r23063 : r23079;
        return r23080;
}

Error

Bits error versus x

Derivation

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

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x}\]

    if -0.02767094041582889 < x < 0.035008502692176

    1. Initial program 63.4

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

    if 0.035008502692176 < 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}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.0

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

Reproduce

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