Average Error: 31.5 → 0.0
Time: 9.5s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.026145755788180215 \lor \neg \left(x \le 0.0289802333023808541\right):\\ \;\;\;\;\frac{x - \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.026145755788180215 \lor \neg \left(x \le 0.0289802333023808541\right):\\
\;\;\;\;\frac{x - \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 r12183 = x;
        double r12184 = sin(r12183);
        double r12185 = r12183 - r12184;
        double r12186 = tan(r12183);
        double r12187 = r12183 - r12186;
        double r12188 = r12185 / r12187;
        return r12188;
}

double f(double x) {
        double r12189 = x;
        double r12190 = -0.026145755788180215;
        bool r12191 = r12189 <= r12190;
        double r12192 = 0.028980233302380854;
        bool r12193 = r12189 <= r12192;
        double r12194 = !r12193;
        bool r12195 = r12191 || r12194;
        double r12196 = sin(r12189);
        double r12197 = r12189 - r12196;
        double r12198 = tan(r12189);
        double r12199 = r12189 - r12198;
        double r12200 = r12197 / r12199;
        double r12201 = 0.225;
        double r12202 = 2.0;
        double r12203 = pow(r12189, r12202);
        double r12204 = 0.009642857142857142;
        double r12205 = 4.0;
        double r12206 = pow(r12189, r12205);
        double r12207 = 0.5;
        double r12208 = fma(r12204, r12206, r12207);
        double r12209 = -r12208;
        double r12210 = fma(r12201, r12203, r12209);
        double r12211 = r12195 ? r12200 : r12210;
        return r12211;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.026145755788180215 or 0.028980233302380854 < x

    1. Initial program 0.1

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

    if -0.026145755788180215 < x < 0.028980233302380854

    1. Initial program 63.0

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