Average Error: 31.1 → 0.0
Time: 4.3m
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.02610929689909074:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.03142629441362508:\\ \;\;\;\;(\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 r7786190 = x;
        double r7786191 = sin(r7786190);
        double r7786192 = r7786190 - r7786191;
        double r7786193 = tan(r7786190);
        double r7786194 = r7786190 - r7786193;
        double r7786195 = r7786192 / r7786194;
        return r7786195;
}

double f(double x) {
        double r7786196 = x;
        double r7786197 = -0.02610929689909074;
        bool r7786198 = r7786196 <= r7786197;
        double r7786199 = tan(r7786196);
        double r7786200 = r7786196 - r7786199;
        double r7786201 = r7786196 / r7786200;
        double r7786202 = sin(r7786196);
        double r7786203 = r7786202 / r7786200;
        double r7786204 = r7786201 - r7786203;
        double r7786205 = 0.03142629441362508;
        bool r7786206 = r7786196 <= r7786205;
        double r7786207 = r7786196 * r7786196;
        double r7786208 = 0.225;
        double r7786209 = -0.009642857142857142;
        double r7786210 = r7786207 * r7786207;
        double r7786211 = -0.5;
        double r7786212 = fma(r7786209, r7786210, r7786211);
        double r7786213 = fma(r7786207, r7786208, r7786212);
        double r7786214 = r7786206 ? r7786213 : r7786204;
        double r7786215 = r7786198 ? r7786204 : r7786214;
        return r7786215;
}

\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
\mathbf{if}\;x \le -0.02610929689909074:\\
\;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\

\mathbf{elif}\;x \le 0.03142629441362508:\\
\;\;\;\;(\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}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.02610929689909074 or 0.03142629441362508 < x

    1. Initial program 0.0

      \[\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.02610929689909074 < x < 0.03142629441362508

    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.02610929689909074:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.03142629441362508:\\ \;\;\;\;(\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 2019102 +o rules:numerics
(FPCore (x)
  :name "sintan (problem 3.4.5)"
  (/ (- x (sin x)) (- x (tan x))))