Average Error: 31.1 → 0.0
Time: 27.5s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.02963816903464042487592600139123533153906:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.02866242393931728651979007338468363741413:\\ \;\;\;\;\frac{9}{40} \cdot {x}^{2} - \mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{\frac{x - \sin x}{x - \tan x}}\right)\\ \end{array}\]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
\mathbf{if}\;x \le -0.02963816903464042487592600139123533153906:\\
\;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\

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

\mathbf{else}:\\
\;\;\;\;\log \left(e^{\frac{x - \sin x}{x - \tan x}}\right)\\

\end{array}
double f(double x) {
        double r24042 = x;
        double r24043 = sin(r24042);
        double r24044 = r24042 - r24043;
        double r24045 = tan(r24042);
        double r24046 = r24042 - r24045;
        double r24047 = r24044 / r24046;
        return r24047;
}

double f(double x) {
        double r24048 = x;
        double r24049 = -0.029638169034640425;
        bool r24050 = r24048 <= r24049;
        double r24051 = tan(r24048);
        double r24052 = r24048 - r24051;
        double r24053 = r24048 / r24052;
        double r24054 = sin(r24048);
        double r24055 = r24054 / r24052;
        double r24056 = r24053 - r24055;
        double r24057 = 0.028662423939317287;
        bool r24058 = r24048 <= r24057;
        double r24059 = 0.225;
        double r24060 = 2.0;
        double r24061 = pow(r24048, r24060);
        double r24062 = r24059 * r24061;
        double r24063 = 0.009642857142857142;
        double r24064 = 4.0;
        double r24065 = pow(r24048, r24064);
        double r24066 = 0.5;
        double r24067 = fma(r24063, r24065, r24066);
        double r24068 = r24062 - r24067;
        double r24069 = r24048 - r24054;
        double r24070 = r24069 / r24052;
        double r24071 = exp(r24070);
        double r24072 = log(r24071);
        double r24073 = r24058 ? r24068 : r24072;
        double r24074 = r24050 ? r24056 : r24073;
        return r24074;
}

Error

Bits error versus x

Derivation

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

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Using strategy rm
    3. Applied div-sub0.0

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

    if -0.029638169034640425 < x < 0.028662423939317287

    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}{\frac{9}{40} \cdot {x}^{2} - \mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)}\]

    if 0.028662423939317287 < x

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Using strategy rm
    3. Applied add-log-exp0.0

      \[\leadsto \color{blue}{\log \left(e^{\frac{x - \sin x}{x - \tan x}}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.0

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

Reproduce

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