Average Error: 31.1 → 0.1
Time: 25.7s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.02976690073964273139384140165475400863215:\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x - \sin x}{x - \tan x}\right)\right)\\ \mathbf{elif}\;x \le 2.491803263157965186991305017727427184582:\\ \;\;\;\;\mathsf{fma}\left(\frac{9}{40}, x \cdot x, \frac{-1}{2}\right) - \frac{27}{2800} \cdot {x}^{4}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{\frac{\sin x}{\cos x}}{x} - \mathsf{fma}\left(\frac{\sin x}{\cos x}, \frac{\sin x}{x \cdot x}, \frac{\sin x}{x}\right)\right) + \mathsf{fma}\left(\frac{\sin x}{{\left(\cos x\right)}^{2}}, \frac{\sin x}{x \cdot x}, 1\right)\\ \end{array}\]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
\mathbf{if}\;x \le -0.02976690073964273139384140165475400863215:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x - \sin x}{x - \tan x}\right)\right)\\

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

\mathbf{else}:\\
\;\;\;\;\left(\frac{\frac{\sin x}{\cos x}}{x} - \mathsf{fma}\left(\frac{\sin x}{\cos x}, \frac{\sin x}{x \cdot x}, \frac{\sin x}{x}\right)\right) + \mathsf{fma}\left(\frac{\sin x}{{\left(\cos x\right)}^{2}}, \frac{\sin x}{x \cdot x}, 1\right)\\

\end{array}
double f(double x) {
        double r23608 = x;
        double r23609 = sin(r23608);
        double r23610 = r23608 - r23609;
        double r23611 = tan(r23608);
        double r23612 = r23608 - r23611;
        double r23613 = r23610 / r23612;
        return r23613;
}

double f(double x) {
        double r23614 = x;
        double r23615 = -0.02976690073964273;
        bool r23616 = r23614 <= r23615;
        double r23617 = sin(r23614);
        double r23618 = r23614 - r23617;
        double r23619 = tan(r23614);
        double r23620 = r23614 - r23619;
        double r23621 = r23618 / r23620;
        double r23622 = log1p(r23621);
        double r23623 = expm1(r23622);
        double r23624 = 2.491803263157965;
        bool r23625 = r23614 <= r23624;
        double r23626 = 0.225;
        double r23627 = r23614 * r23614;
        double r23628 = -0.5;
        double r23629 = fma(r23626, r23627, r23628);
        double r23630 = 0.009642857142857142;
        double r23631 = 4.0;
        double r23632 = pow(r23614, r23631);
        double r23633 = r23630 * r23632;
        double r23634 = r23629 - r23633;
        double r23635 = cos(r23614);
        double r23636 = r23617 / r23635;
        double r23637 = r23636 / r23614;
        double r23638 = r23617 / r23627;
        double r23639 = r23617 / r23614;
        double r23640 = fma(r23636, r23638, r23639);
        double r23641 = r23637 - r23640;
        double r23642 = 2.0;
        double r23643 = pow(r23635, r23642);
        double r23644 = r23617 / r23643;
        double r23645 = 1.0;
        double r23646 = fma(r23644, r23638, r23645);
        double r23647 = r23641 + r23646;
        double r23648 = r23625 ? r23634 : r23647;
        double r23649 = r23616 ? r23623 : r23648;
        return r23649;
}

Error

Bits error versus x

Derivation

  1. Split input into 3 regimes
  2. if x < -0.02976690073964273

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Using strategy rm
    3. Applied expm1-log1p-u0.0

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x - \sin x}{x - \tan x}\right)\right)}\]

    if -0.02976690073964273 < x < 2.491803263157965

    1. Initial program 63.0

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{9}{40}, x \cdot x, \frac{-1}{2}\right) - {x}^{4} \cdot \frac{27}{2800}}\]

    if 2.491803263157965 < x

    1. Initial program 0.0

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\sin x}{{\left(\cos x\right)}^{2}}, \frac{\sin x}{x \cdot x}, 1\right) + \left(\frac{\frac{\sin x}{\cos x}}{x} - \mathsf{fma}\left(\frac{\sin x}{\cos x}, \frac{\sin x}{x \cdot x}, \frac{\sin x}{x}\right)\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.02976690073964273139384140165475400863215:\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x - \sin x}{x - \tan x}\right)\right)\\ \mathbf{elif}\;x \le 2.491803263157965186991305017727427184582:\\ \;\;\;\;\mathsf{fma}\left(\frac{9}{40}, x \cdot x, \frac{-1}{2}\right) - \frac{27}{2800} \cdot {x}^{4}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{\frac{\sin x}{\cos x}}{x} - \mathsf{fma}\left(\frac{\sin x}{\cos x}, \frac{\sin x}{x \cdot x}, \frac{\sin x}{x}\right)\right) + \mathsf{fma}\left(\frac{\sin x}{{\left(\cos x\right)}^{2}}, \frac{\sin x}{x \cdot x}, 1\right)\\ \end{array}\]

Reproduce

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