Average Error: 31.6 → 0.0
Time: 8.8s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.024514420160319003 \lor \neg \left(x \le 0.0285174389981211092\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.024514420160319003 \lor \neg \left(x \le 0.0285174389981211092\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 r8026 = x;
        double r8027 = sin(r8026);
        double r8028 = r8026 - r8027;
        double r8029 = tan(r8026);
        double r8030 = r8026 - r8029;
        double r8031 = r8028 / r8030;
        return r8031;
}

double f(double x) {
        double r8032 = x;
        double r8033 = -0.024514420160319003;
        bool r8034 = r8032 <= r8033;
        double r8035 = 0.02851743899812111;
        bool r8036 = r8032 <= r8035;
        double r8037 = !r8036;
        bool r8038 = r8034 || r8037;
        double r8039 = sin(r8032);
        double r8040 = r8032 - r8039;
        double r8041 = tan(r8032);
        double r8042 = r8032 - r8041;
        double r8043 = r8040 / r8042;
        double r8044 = 0.225;
        double r8045 = 2.0;
        double r8046 = pow(r8032, r8045);
        double r8047 = 0.009642857142857142;
        double r8048 = 4.0;
        double r8049 = pow(r8032, r8048);
        double r8050 = 0.5;
        double r8051 = fma(r8047, r8049, r8050);
        double r8052 = -r8051;
        double r8053 = fma(r8044, r8046, r8052);
        double r8054 = r8038 ? r8043 : r8053;
        return r8054;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.024514420160319003 or 0.02851743899812111 < x

    1. Initial program 0.1

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

    if -0.024514420160319003 < x < 0.02851743899812111

    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)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.024514420160319003 \lor \neg \left(x \le 0.0285174389981211092\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 2020020 +o rules:numerics
(FPCore (x)
  :name "sintan (problem 3.4.5)"
  :precision binary64
  (/ (- x (sin x)) (- x (tan x))))