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

\mathbf{elif}\;x \le 0.031240215431948184:\\
\;\;\;\;\frac{9}{40} \cdot \left(x \cdot x\right) - \mathsf{fma}\left(\frac{27}{2800}, \left(x \cdot x\right) \cdot \left(x \cdot x\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 r445510 = x;
        double r445511 = sin(r445510);
        double r445512 = r445510 - r445511;
        double r445513 = tan(r445510);
        double r445514 = r445510 - r445513;
        double r445515 = r445512 / r445514;
        return r445515;
}

double f(double x) {
        double r445516 = x;
        double r445517 = -0.028213729881585915;
        bool r445518 = r445516 <= r445517;
        double r445519 = tan(r445516);
        double r445520 = r445516 - r445519;
        double r445521 = r445516 / r445520;
        double r445522 = sin(r445516);
        double r445523 = r445522 / r445520;
        double r445524 = r445521 - r445523;
        double r445525 = 0.031240215431948184;
        bool r445526 = r445516 <= r445525;
        double r445527 = 0.225;
        double r445528 = r445516 * r445516;
        double r445529 = r445527 * r445528;
        double r445530 = 0.009642857142857142;
        double r445531 = r445528 * r445528;
        double r445532 = 0.5;
        double r445533 = fma(r445530, r445531, r445532);
        double r445534 = r445529 - r445533;
        double r445535 = r445526 ? r445534 : r445524;
        double r445536 = r445518 ? r445524 : r445535;
        return r445536;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.028213729881585915 or 0.031240215431948184 < x

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Using strategy rm
    3. Applied add-log-exp0.1

      \[\leadsto \color{blue}{\log \left(e^{\frac{x - \sin x}{x - \tan x}}\right)}\]
    4. Using strategy rm
    5. Applied div-sub0.1

      \[\leadsto \log \left(e^{\color{blue}{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}}}\right)\]
    6. Applied exp-diff0.1

      \[\leadsto \log \color{blue}{\left(\frac{e^{\frac{x}{x - \tan x}}}{e^{\frac{\sin x}{x - \tan x}}}\right)}\]
    7. Applied log-div0.1

      \[\leadsto \color{blue}{\log \left(e^{\frac{x}{x - \tan x}}\right) - \log \left(e^{\frac{\sin x}{x - \tan x}}\right)}\]
    8. Simplified0.1

      \[\leadsto \color{blue}{\frac{x}{x - \tan x}} - \log \left(e^{\frac{\sin x}{x - \tan x}}\right)\]
    9. Simplified0.1

      \[\leadsto \frac{x}{x - \tan x} - \color{blue}{\frac{\sin x}{x - \tan x}}\]

    if -0.028213729881585915 < x < 0.031240215431948184

    1. Initial program 62.8

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Using strategy rm
    3. Applied add-log-exp62.8

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

Reproduce

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