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

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

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

\end{array}
double f(double x) {
        double r745808 = x;
        double r745809 = sin(r745808);
        double r745810 = r745808 - r745809;
        double r745811 = tan(r745808);
        double r745812 = r745808 - r745811;
        double r745813 = r745810 / r745812;
        return r745813;
}

double f(double x) {
        double r745814 = x;
        double r745815 = -0.030080749048725534;
        bool r745816 = r745814 <= r745815;
        double r745817 = tan(r745814);
        double r745818 = r745814 - r745817;
        double r745819 = r745814 / r745818;
        double r745820 = sin(r745814);
        double r745821 = r745820 / r745818;
        double r745822 = r745819 - r745821;
        double r745823 = 0.03226417837547404;
        bool r745824 = r745814 <= r745823;
        double r745825 = r745814 * r745814;
        double r745826 = 0.225;
        double r745827 = r745825 * r745826;
        double r745828 = 0.009642857142857142;
        double r745829 = r745825 * r745825;
        double r745830 = 0.5;
        double r745831 = fma(r745828, r745829, r745830);
        double r745832 = r745827 - r745831;
        double r745833 = r745824 ? r745832 : r745822;
        double r745834 = r745816 ? r745822 : r745833;
        return r745834;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.030080749048725534 or 0.03226417837547404 < 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.030080749048725534 < x < 0.03226417837547404

    1. Initial program 62.8

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

      \[\leadsto \color{blue}{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}}\]
    4. 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)}\]
    5. Simplified0.0

      \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \frac{9}{40} - \mathsf{fma}\left(\frac{27}{2800}, \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right), \frac{1}{2}\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

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

Reproduce

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