Average Error: 31.3 → 0.3
Time: 9.7s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.4354142091382851 \lor \neg \left(x \le 2.4300372653342581\right):\\ \;\;\;\;\left(\frac{\sin x}{x \cdot \cos x} + \left(\frac{{\left(\sin x\right)}^{2}}{{x}^{2} \cdot {\left(\cos x\right)}^{2}} + 1\right)\right) - \left(\frac{\sin x}{x} + \frac{{\left(\sin x\right)}^{2}}{{x}^{2} \cdot \cos x}\right)\\ \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 -2.4354142091382851 \lor \neg \left(x \le 2.4300372653342581\right):\\
\;\;\;\;\left(\frac{\sin x}{x \cdot \cos x} + \left(\frac{{\left(\sin x\right)}^{2}}{{x}^{2} \cdot {\left(\cos x\right)}^{2}} + 1\right)\right) - \left(\frac{\sin x}{x} + \frac{{\left(\sin x\right)}^{2}}{{x}^{2} \cdot \cos x}\right)\\

\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 r12586 = x;
        double r12587 = sin(r12586);
        double r12588 = r12586 - r12587;
        double r12589 = tan(r12586);
        double r12590 = r12586 - r12589;
        double r12591 = r12588 / r12590;
        return r12591;
}

double f(double x) {
        double r12592 = x;
        double r12593 = -2.435414209138285;
        bool r12594 = r12592 <= r12593;
        double r12595 = 2.430037265334258;
        bool r12596 = r12592 <= r12595;
        double r12597 = !r12596;
        bool r12598 = r12594 || r12597;
        double r12599 = sin(r12592);
        double r12600 = cos(r12592);
        double r12601 = r12592 * r12600;
        double r12602 = r12599 / r12601;
        double r12603 = 2.0;
        double r12604 = pow(r12599, r12603);
        double r12605 = pow(r12592, r12603);
        double r12606 = pow(r12600, r12603);
        double r12607 = r12605 * r12606;
        double r12608 = r12604 / r12607;
        double r12609 = 1.0;
        double r12610 = r12608 + r12609;
        double r12611 = r12602 + r12610;
        double r12612 = r12599 / r12592;
        double r12613 = r12605 * r12600;
        double r12614 = r12604 / r12613;
        double r12615 = r12612 + r12614;
        double r12616 = r12611 - r12615;
        double r12617 = 0.225;
        double r12618 = 0.009642857142857142;
        double r12619 = 4.0;
        double r12620 = pow(r12592, r12619);
        double r12621 = 0.5;
        double r12622 = fma(r12618, r12620, r12621);
        double r12623 = -r12622;
        double r12624 = fma(r12617, r12605, r12623);
        double r12625 = r12598 ? r12616 : r12624;
        return r12625;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -2.435414209138285 or 2.430037265334258 < x

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Taylor expanded around inf 0.4

      \[\leadsto \color{blue}{\left(\frac{\sin x}{x \cdot \cos x} + \left(\frac{{\left(\sin x\right)}^{2}}{{x}^{2} \cdot {\left(\cos x\right)}^{2}} + 1\right)\right) - \left(\frac{\sin x}{x} + \frac{{\left(\sin x\right)}^{2}}{{x}^{2} \cdot \cos x}\right)}\]

    if -2.435414209138285 < x < 2.430037265334258

    1. Initial program 62.8

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Taylor expanded around 0 0.2

      \[\leadsto \color{blue}{\frac{9}{40} \cdot {x}^{2} - \left(\frac{27}{2800} \cdot {x}^{4} + \frac{1}{2}\right)}\]
    3. Simplified0.2

      \[\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.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.4354142091382851 \lor \neg \left(x \le 2.4300372653342581\right):\\ \;\;\;\;\left(\frac{\sin x}{x \cdot \cos x} + \left(\frac{{\left(\sin x\right)}^{2}}{{x}^{2} \cdot {\left(\cos x\right)}^{2}} + 1\right)\right) - \left(\frac{\sin x}{x} + \frac{{\left(\sin x\right)}^{2}}{{x}^{2} \cdot \cos x}\right)\\ \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 2020024 +o rules:numerics
(FPCore (x)
  :name "sintan (problem 3.4.5)"
  :precision binary64
  (/ (- x (sin x)) (- x (tan x))))