Average Error: 31.3 → 0.0
Time: 10.2s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.0278192048020163 \lor \neg \left(x \le 0.029072884728966221\right):\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x - \sin x}{x - \tan x}\right)\right)\\ \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.0278192048020163 \lor \neg \left(x \le 0.029072884728966221\right):\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x - \sin x}{x - \tan x}\right)\right)\\

\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 r12940 = x;
        double r12941 = sin(r12940);
        double r12942 = r12940 - r12941;
        double r12943 = tan(r12940);
        double r12944 = r12940 - r12943;
        double r12945 = r12942 / r12944;
        return r12945;
}

double f(double x) {
        double r12946 = x;
        double r12947 = -0.027819204802016273;
        bool r12948 = r12946 <= r12947;
        double r12949 = 0.02907288472896622;
        bool r12950 = r12946 <= r12949;
        double r12951 = !r12950;
        bool r12952 = r12948 || r12951;
        double r12953 = sin(r12946);
        double r12954 = r12946 - r12953;
        double r12955 = tan(r12946);
        double r12956 = r12946 - r12955;
        double r12957 = r12954 / r12956;
        double r12958 = log1p(r12957);
        double r12959 = expm1(r12958);
        double r12960 = 0.225;
        double r12961 = 2.0;
        double r12962 = pow(r12946, r12961);
        double r12963 = 0.009642857142857142;
        double r12964 = 4.0;
        double r12965 = pow(r12946, r12964);
        double r12966 = 0.5;
        double r12967 = fma(r12963, r12965, r12966);
        double r12968 = -r12967;
        double r12969 = fma(r12960, r12962, r12968);
        double r12970 = r12952 ? r12959 : r12969;
        return r12970;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.027819204802016273 or 0.02907288472896622 < x

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Using strategy rm
    3. Applied expm1-log1p-u0.1

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x - \sin x}{x - \tan x}\right)\right)}\]

    if -0.027819204802016273 < x < 0.02907288472896622

    1. Initial program 63.1

      \[\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.0278192048020163 \lor \neg \left(x \le 0.029072884728966221\right):\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x - \sin x}{x - \tan x}\right)\right)\\ \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 2020081 +o rules:numerics
(FPCore (x)
  :name "sintan (problem 3.4.5)"
  :precision binary64
  (/ (- x (sin x)) (- x (tan x))))