Average Error: 31.2 → 0.0
Time: 35.2s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.029021700279035747:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.029500701526914974:\\ \;\;\;\;\mathsf{fma}\left(\frac{9}{40}, x \cdot x, -\mathsf{fma}\left(\frac{27}{2800}, \left(x \cdot x\right) \cdot \left(x \cdot x\right), \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.029021700279035747:\\
\;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\

\mathbf{elif}\;x \le 0.029500701526914974:\\
\;\;\;\;\mathsf{fma}\left(\frac{9}{40}, x \cdot x, -\mathsf{fma}\left(\frac{27}{2800}, \left(x \cdot x\right) \cdot \left(x \cdot x\right), \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 r436625 = x;
        double r436626 = sin(r436625);
        double r436627 = r436625 - r436626;
        double r436628 = tan(r436625);
        double r436629 = r436625 - r436628;
        double r436630 = r436627 / r436629;
        return r436630;
}

double f(double x) {
        double r436631 = x;
        double r436632 = -0.029021700279035747;
        bool r436633 = r436631 <= r436632;
        double r436634 = tan(r436631);
        double r436635 = r436631 - r436634;
        double r436636 = r436631 / r436635;
        double r436637 = sin(r436631);
        double r436638 = r436637 / r436635;
        double r436639 = r436636 - r436638;
        double r436640 = 0.029500701526914974;
        bool r436641 = r436631 <= r436640;
        double r436642 = 0.225;
        double r436643 = r436631 * r436631;
        double r436644 = 0.009642857142857142;
        double r436645 = r436643 * r436643;
        double r436646 = 0.5;
        double r436647 = fma(r436644, r436645, r436646);
        double r436648 = -r436647;
        double r436649 = fma(r436642, r436643, r436648);
        double r436650 = r436641 ? r436649 : r436639;
        double r436651 = r436633 ? r436639 : r436650;
        return r436651;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.029021700279035747 or 0.029500701526914974 < x

    1. Initial program 0.1

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

    if -0.029021700279035747 < x < 0.029500701526914974

    1. Initial program 62.9

      \[\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 \cdot x, -\mathsf{fma}\left(\frac{27}{2800}, \left(x \cdot x\right) \cdot \left(x \cdot x\right), \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.029021700279035747:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.029500701526914974:\\ \;\;\;\;\mathsf{fma}\left(\frac{9}{40}, x \cdot x, -\mathsf{fma}\left(\frac{27}{2800}, \left(x \cdot x\right) \cdot \left(x \cdot x\right), \frac{1}{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \end{array}\]

Reproduce

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