Average Error: 31.4 → 0.0
Time: 4.1m
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.0343675887053717:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.03216989433394439:\\ \;\;\;\;(\left(x \cdot x\right) \cdot \frac{9}{40} + \left((\frac{-27}{2800} \cdot \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.0343675887053717:\\
\;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\

\mathbf{elif}\;x \le 0.03216989433394439:\\
\;\;\;\;(\left(x \cdot x\right) \cdot \frac{9}{40} + \left((\frac{-27}{2800} \cdot \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 r7532152 = x;
        double r7532153 = sin(r7532152);
        double r7532154 = r7532152 - r7532153;
        double r7532155 = tan(r7532152);
        double r7532156 = r7532152 - r7532155;
        double r7532157 = r7532154 / r7532156;
        return r7532157;
}

double f(double x) {
        double r7532158 = x;
        double r7532159 = -0.0343675887053717;
        bool r7532160 = r7532158 <= r7532159;
        double r7532161 = tan(r7532158);
        double r7532162 = r7532158 - r7532161;
        double r7532163 = r7532158 / r7532162;
        double r7532164 = sin(r7532158);
        double r7532165 = r7532164 / r7532162;
        double r7532166 = r7532163 - r7532165;
        double r7532167 = 0.03216989433394439;
        bool r7532168 = r7532158 <= r7532167;
        double r7532169 = r7532158 * r7532158;
        double r7532170 = 0.225;
        double r7532171 = -0.009642857142857142;
        double r7532172 = r7532169 * r7532169;
        double r7532173 = -0.5;
        double r7532174 = fma(r7532171, r7532172, r7532173);
        double r7532175 = fma(r7532169, r7532170, r7532174);
        double r7532176 = r7532168 ? r7532175 : r7532166;
        double r7532177 = r7532160 ? r7532166 : r7532176;
        return r7532177;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.0343675887053717 or 0.03216989433394439 < x

    1. Initial program 0.0

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

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

    if -0.0343675887053717 < x < 0.03216989433394439

    1. Initial program 62.7

      \[\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}{(\left(x \cdot x\right) \cdot \frac{9}{40} + \left((\frac{-27}{2800} \cdot \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.0343675887053717:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.03216989433394439:\\ \;\;\;\;(\left(x \cdot x\right) \cdot \frac{9}{40} + \left((\frac{-27}{2800} \cdot \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 2019112 +o rules:numerics
(FPCore (x)
  :name "sintan (problem 3.4.5)"
  (/ (- x (sin x)) (- x (tan x))))