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

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

\end{array}
double f(double x) {
        double r9686 = x;
        double r9687 = sin(r9686);
        double r9688 = r9686 - r9687;
        double r9689 = tan(r9686);
        double r9690 = r9686 - r9689;
        double r9691 = r9688 / r9690;
        return r9691;
}

double f(double x) {
        double r9692 = x;
        double r9693 = -0.026775790768781334;
        bool r9694 = r9692 <= r9693;
        double r9695 = 0.02869830051678616;
        bool r9696 = r9692 <= r9695;
        double r9697 = !r9696;
        bool r9698 = r9694 || r9697;
        double r9699 = sin(r9692);
        double r9700 = r9692 - r9699;
        double r9701 = tan(r9692);
        double r9702 = r9692 - r9701;
        double r9703 = r9700 / r9702;
        double r9704 = 0.225;
        double r9705 = 2.0;
        double r9706 = pow(r9692, r9705);
        double r9707 = r9704 * r9706;
        double r9708 = 0.009642857142857142;
        double r9709 = 4.0;
        double r9710 = pow(r9692, r9709);
        double r9711 = 0.5;
        double r9712 = fma(r9708, r9710, r9711);
        double r9713 = r9707 - r9712;
        double r9714 = r9698 ? r9703 : r9713;
        return r9714;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.026775790768781334 or 0.02869830051678616 < x

    1. Initial program 0.0

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

    if -0.026775790768781334 < x < 0.02869830051678616

    1. Initial program 63.3

      \[\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}{\frac{9}{40} \cdot {x}^{2} - \mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

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

Reproduce

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