Average Error: 31.2 → 0.0
Time: 45.8s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.02651353729569189:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.02912476454801862:\\ \;\;\;\;\mathsf{fma}\left(\left(x \cdot x\right), \left(\mathsf{fma}\left(\left(x \cdot x\right), \frac{-27}{2800}, \frac{9}{40}\right)\right), \frac{-1}{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \end{array}\]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
\mathbf{if}\;x \le -0.02651353729569189:\\
\;\;\;\;\frac{x - \sin x}{x - \tan x}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{x - \sin x}{x - \tan x}\\

\end{array}
double f(double x) {
        double r1001626 = x;
        double r1001627 = sin(r1001626);
        double r1001628 = r1001626 - r1001627;
        double r1001629 = tan(r1001626);
        double r1001630 = r1001626 - r1001629;
        double r1001631 = r1001628 / r1001630;
        return r1001631;
}

double f(double x) {
        double r1001632 = x;
        double r1001633 = -0.02651353729569189;
        bool r1001634 = r1001632 <= r1001633;
        double r1001635 = sin(r1001632);
        double r1001636 = r1001632 - r1001635;
        double r1001637 = tan(r1001632);
        double r1001638 = r1001632 - r1001637;
        double r1001639 = r1001636 / r1001638;
        double r1001640 = 0.02912476454801862;
        bool r1001641 = r1001632 <= r1001640;
        double r1001642 = r1001632 * r1001632;
        double r1001643 = -0.009642857142857142;
        double r1001644 = 0.225;
        double r1001645 = fma(r1001642, r1001643, r1001644);
        double r1001646 = -0.5;
        double r1001647 = fma(r1001642, r1001645, r1001646);
        double r1001648 = r1001641 ? r1001647 : r1001639;
        double r1001649 = r1001634 ? r1001639 : r1001648;
        return r1001649;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.02651353729569189 or 0.02912476454801862 < x

    1. Initial program 0.1

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

      \[\leadsto \frac{\color{blue}{x - \sin x}}{x - \tan x}\]

    if -0.02651353729569189 < x < 0.02912476454801862

    1. Initial program 62.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.02651353729569189:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.02912476454801862:\\ \;\;\;\;\mathsf{fma}\left(\left(x \cdot x\right), \left(\mathsf{fma}\left(\left(x \cdot x\right), \frac{-27}{2800}, \frac{9}{40}\right)\right), \frac{-1}{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \end{array}\]

Reproduce

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