Average Error: 31.6 → 0.0
Time: 11.2s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.02780120038993252190584470895373669918627 \lor \neg \left(x \le 0.02674499741262323024293401374507084256038\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.02780120038993252190584470895373669918627 \lor \neg \left(x \le 0.02674499741262323024293401374507084256038\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 r21555 = x;
        double r21556 = sin(r21555);
        double r21557 = r21555 - r21556;
        double r21558 = tan(r21555);
        double r21559 = r21555 - r21558;
        double r21560 = r21557 / r21559;
        return r21560;
}

double f(double x) {
        double r21561 = x;
        double r21562 = -0.027801200389932522;
        bool r21563 = r21561 <= r21562;
        double r21564 = 0.02674499741262323;
        bool r21565 = r21561 <= r21564;
        double r21566 = !r21565;
        bool r21567 = r21563 || r21566;
        double r21568 = sin(r21561);
        double r21569 = r21561 - r21568;
        double r21570 = tan(r21561);
        double r21571 = r21561 - r21570;
        double r21572 = r21569 / r21571;
        double r21573 = 0.225;
        double r21574 = 2.0;
        double r21575 = pow(r21561, r21574);
        double r21576 = 0.009642857142857142;
        double r21577 = 4.0;
        double r21578 = pow(r21561, r21577);
        double r21579 = 0.5;
        double r21580 = fma(r21576, r21578, r21579);
        double r21581 = -r21580;
        double r21582 = fma(r21573, r21575, r21581);
        double r21583 = r21567 ? r21572 : r21582;
        return r21583;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.027801200389932522 or 0.02674499741262323 < x

    1. Initial program 0.0

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

    if -0.027801200389932522 < x < 0.02674499741262323

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.02780120038993252190584470895373669918627 \lor \neg \left(x \le 0.02674499741262323024293401374507084256038\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 2019347 +o rules:numerics
(FPCore (x)
  :name "sintan (problem 3.4.5)"
  :precision binary64
  (/ (- x (sin x)) (- x (tan x))))