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

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

\end{array}
double f(double x) {
        double r10692 = x;
        double r10693 = sin(r10692);
        double r10694 = r10692 - r10693;
        double r10695 = tan(r10692);
        double r10696 = r10692 - r10695;
        double r10697 = r10694 / r10696;
        return r10697;
}

double f(double x) {
        double r10698 = x;
        double r10699 = -0.030137210439935006;
        bool r10700 = r10698 <= r10699;
        double r10701 = 0.028890275250899152;
        bool r10702 = r10698 <= r10701;
        double r10703 = !r10702;
        bool r10704 = r10700 || r10703;
        double r10705 = sin(r10698);
        double r10706 = r10698 - r10705;
        double r10707 = tan(r10698);
        double r10708 = r10698 - r10707;
        double r10709 = r10706 / r10708;
        double r10710 = 0.225;
        double r10711 = 2.0;
        double r10712 = pow(r10698, r10711);
        double r10713 = 0.009642857142857142;
        double r10714 = 4.0;
        double r10715 = pow(r10698, r10714);
        double r10716 = 0.5;
        double r10717 = fma(r10713, r10715, r10716);
        double r10718 = -r10717;
        double r10719 = fma(r10710, r10712, r10718);
        double r10720 = expm1(r10719);
        double r10721 = log1p(r10720);
        double r10722 = r10704 ? r10709 : r10721;
        return r10722;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.030137210439935006 or 0.028890275250899152 < x

    1. Initial program 0.0

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

    if -0.030137210439935006 < x < 0.028890275250899152

    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)}\]
    4. Using strategy rm
    5. Applied log1p-expm1-u0.0

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{fma}\left(\frac{9}{40}, {x}^{2}, -\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right)\right)\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.0301372104399350062 \lor \neg \left(x \le 0.0288902752508991521\right):\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{fma}\left(\frac{9}{40}, {x}^{2}, -\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right)\right)\right)\\ \end{array}\]

Reproduce

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