Average Error: 31.3 → 0.0
Time: 12.2s
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 r8757 = x;
        double r8758 = sin(r8757);
        double r8759 = r8757 - r8758;
        double r8760 = tan(r8757);
        double r8761 = r8757 - r8760;
        double r8762 = r8759 / r8761;
        return r8762;
}

double f(double x) {
        double r8763 = x;
        double r8764 = -0.026775790768781334;
        bool r8765 = r8763 <= r8764;
        double r8766 = 0.02869830051678616;
        bool r8767 = r8763 <= r8766;
        double r8768 = !r8767;
        bool r8769 = r8765 || r8768;
        double r8770 = sin(r8763);
        double r8771 = r8763 - r8770;
        double r8772 = tan(r8763);
        double r8773 = r8763 - r8772;
        double r8774 = r8771 / r8773;
        double r8775 = 0.225;
        double r8776 = 2.0;
        double r8777 = pow(r8763, r8776);
        double r8778 = r8775 * r8777;
        double r8779 = 0.009642857142857142;
        double r8780 = 4.0;
        double r8781 = pow(r8763, r8780);
        double r8782 = 0.5;
        double r8783 = fma(r8779, r8781, r8782);
        double r8784 = r8778 - r8783;
        double r8785 = r8769 ? r8774 : r8784;
        return r8785;
}

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))))