Average Error: 31.5 → 0.0
Time: 9.5s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.037455433778870853:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x - \sin x}{x - \tan x}\right)\right)\\ \mathbf{elif}\;x \le 0.038612806086461615:\\ \;\;\;\;\mathsf{log1p}\left(e^{\frac{-1}{2}} \cdot \left(\frac{9}{40} \cdot {x}^{2} + {x}^{4} \cdot \frac{351}{22400}\right) + \mathsf{expm1}\left(\frac{-1}{2}\right)\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.037455433778870853:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x - \sin x}{x - \tan x}\right)\right)\\

\mathbf{elif}\;x \le 0.038612806086461615:\\
\;\;\;\;\mathsf{log1p}\left(e^{\frac{-1}{2}} \cdot \left(\frac{9}{40} \cdot {x}^{2} + {x}^{4} \cdot \frac{351}{22400}\right) + \mathsf{expm1}\left(\frac{-1}{2}\right)\right)\\

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

\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.03745543377887085;
        bool r14550 = r14548 <= r14549;
        double r14551 = sin(r14548);
        double r14552 = r14548 - r14551;
        double r14553 = tan(r14548);
        double r14554 = r14548 - r14553;
        double r14555 = r14552 / r14554;
        double r14556 = expm1(r14555);
        double r14557 = log1p(r14556);
        double r14558 = 0.038612806086461615;
        bool r14559 = r14548 <= r14558;
        double r14560 = -0.5;
        double r14561 = exp(r14560);
        double r14562 = 0.225;
        double r14563 = 2.0;
        double r14564 = pow(r14548, r14563);
        double r14565 = r14562 * r14564;
        double r14566 = 4.0;
        double r14567 = pow(r14548, r14566);
        double r14568 = 0.015669642857142858;
        double r14569 = r14567 * r14568;
        double r14570 = r14565 + r14569;
        double r14571 = r14561 * r14570;
        double r14572 = expm1(r14560);
        double r14573 = r14571 + r14572;
        double r14574 = log1p(r14573);
        double r14575 = r14559 ? r14574 : r14555;
        double r14576 = r14550 ? r14557 : r14575;
        return r14576;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if x < -0.03745543377887085

    1. Initial program 0.1

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

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

    if -0.03745543377887085 < x < 0.038612806086461615

    1. Initial program 63.1

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

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x - \sin x}{x - \tan x}\right)\right)}\]
    4. Taylor expanded around 0 0.0

      \[\leadsto \mathsf{log1p}\left(\color{blue}{\left(\frac{9}{40} \cdot \left(e^{\frac{-1}{2}} \cdot {x}^{2}\right) + \left(e^{\frac{-1}{2}} + \frac{351}{22400} \cdot \left(e^{\frac{-1}{2}} \cdot {x}^{4}\right)\right)\right) - 1}\right)\]
    5. Simplified0.0

      \[\leadsto \mathsf{log1p}\left(\color{blue}{e^{\frac{-1}{2}} \cdot \left(\frac{9}{40} \cdot {x}^{2} + {x}^{4} \cdot \frac{351}{22400}\right) + \mathsf{expm1}\left(\frac{-1}{2}\right)}\right)\]

    if 0.038612806086461615 < x

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.037455433778870853:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x - \sin x}{x - \tan x}\right)\right)\\ \mathbf{elif}\;x \le 0.038612806086461615:\\ \;\;\;\;\mathsf{log1p}\left(e^{\frac{-1}{2}} \cdot \left(\frac{9}{40} \cdot {x}^{2} + {x}^{4} \cdot \frac{351}{22400}\right) + \mathsf{expm1}\left(\frac{-1}{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \end{array}\]

Reproduce

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