Average Error: 30.8 → 0.0
Time: 10.2s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.0289755674093477682 \lor \neg \left(x \le 0.028954196312268393\right):\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{9}{40}, {x}^{2}, -\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right)\\ \end{array}\]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
\mathbf{if}\;x \le -0.0289755674093477682 \lor \neg \left(x \le 0.028954196312268393\right):\\
\;\;\;\;\frac{x - \sin x}{x - \tan x}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{9}{40}, {x}^{2}, -\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right)\\

\end{array}
double f(double x) {
        double r14268 = x;
        double r14269 = sin(r14268);
        double r14270 = r14268 - r14269;
        double r14271 = tan(r14268);
        double r14272 = r14268 - r14271;
        double r14273 = r14270 / r14272;
        return r14273;
}

double f(double x) {
        double r14274 = x;
        double r14275 = -0.028975567409347768;
        bool r14276 = r14274 <= r14275;
        double r14277 = 0.028954196312268393;
        bool r14278 = r14274 <= r14277;
        double r14279 = !r14278;
        bool r14280 = r14276 || r14279;
        double r14281 = sin(r14274);
        double r14282 = r14274 - r14281;
        double r14283 = tan(r14274);
        double r14284 = r14274 - r14283;
        double r14285 = r14282 / r14284;
        double r14286 = 0.225;
        double r14287 = 2.0;
        double r14288 = pow(r14274, r14287);
        double r14289 = 0.009642857142857142;
        double r14290 = 4.0;
        double r14291 = pow(r14274, r14290);
        double r14292 = 0.5;
        double r14293 = fma(r14289, r14291, r14292);
        double r14294 = -r14293;
        double r14295 = fma(r14286, r14288, r14294);
        double r14296 = r14280 ? r14285 : r14295;
        return r14296;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.028975567409347768 or 0.028954196312268393 < x

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x}\]

    if -0.028975567409347768 < x < 0.028954196312268393

    1. Initial program 63.2

      \[\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}^{2}, -\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \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.0289755674093477682 \lor \neg \left(x \le 0.028954196312268393\right):\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{9}{40}, {x}^{2}, -\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right)\\ \end{array}\]

Reproduce

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