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

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

\end{array}
double f(double x) {
        double r14542 = x;
        double r14543 = sin(r14542);
        double r14544 = r14542 - r14543;
        double r14545 = tan(r14542);
        double r14546 = r14542 - r14545;
        double r14547 = r14544 / r14546;
        return r14547;
}

double f(double x) {
        double r14548 = x;
        double r14549 = -0.024389077621678308;
        bool r14550 = r14548 <= r14549;
        double r14551 = 0.01861232521167047;
        bool r14552 = r14548 <= r14551;
        double r14553 = !r14552;
        bool r14554 = r14550 || r14553;
        double r14555 = sin(r14548);
        double r14556 = r14548 - r14555;
        double r14557 = tan(r14548);
        double r14558 = r14548 - r14557;
        double r14559 = r14556 / r14558;
        double r14560 = 0.225;
        double r14561 = 2.0;
        double r14562 = pow(r14548, r14561);
        double r14563 = 0.009642857142857142;
        double r14564 = 4.0;
        double r14565 = pow(r14548, r14564);
        double r14566 = 0.5;
        double r14567 = fma(r14563, r14565, r14566);
        double r14568 = -r14567;
        double r14569 = fma(r14560, r14562, r14568);
        double r14570 = r14554 ? r14559 : r14569;
        return r14570;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.024389077621678308 or 0.01861232521167047 < x

    1. Initial program 0.1

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

    if -0.024389077621678308 < x < 0.01861232521167047

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

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

Reproduce

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