Average Error: 30.8 → 0.0
Time: 33.7s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.027836888459983777:\\ \;\;\;\;\log \left(e^{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}}\right)\\ \mathbf{elif}\;x \le 0.02825639784178301:\\ \;\;\;\;\left(x \cdot x\right) \cdot \frac{9}{40} - \mathsf{fma}\left(\frac{27}{2800}, \left(x \cdot x\right) \cdot \left(x \cdot x\right), \frac{1}{2}\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.027836888459983777:\\
\;\;\;\;\log \left(e^{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}}\right)\\

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

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

\end{array}
double f(double x) {
        double r916055 = x;
        double r916056 = sin(r916055);
        double r916057 = r916055 - r916056;
        double r916058 = tan(r916055);
        double r916059 = r916055 - r916058;
        double r916060 = r916057 / r916059;
        return r916060;
}

double f(double x) {
        double r916061 = x;
        double r916062 = -0.027836888459983777;
        bool r916063 = r916061 <= r916062;
        double r916064 = tan(r916061);
        double r916065 = r916061 - r916064;
        double r916066 = r916061 / r916065;
        double r916067 = sin(r916061);
        double r916068 = r916067 / r916065;
        double r916069 = r916066 - r916068;
        double r916070 = exp(r916069);
        double r916071 = log(r916070);
        double r916072 = 0.02825639784178301;
        bool r916073 = r916061 <= r916072;
        double r916074 = r916061 * r916061;
        double r916075 = 0.225;
        double r916076 = r916074 * r916075;
        double r916077 = 0.009642857142857142;
        double r916078 = r916074 * r916074;
        double r916079 = 0.5;
        double r916080 = fma(r916077, r916078, r916079);
        double r916081 = r916076 - r916080;
        double r916082 = r916061 - r916067;
        double r916083 = r916082 / r916065;
        double r916084 = r916073 ? r916081 : r916083;
        double r916085 = r916063 ? r916071 : r916084;
        return r916085;
}

Error

Bits error versus x

Derivation

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

    1. Initial program 0.1

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

      \[\leadsto \color{blue}{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}}\]
    4. Using strategy rm
    5. Applied add-log-exp0.1

      \[\leadsto \frac{x}{x - \tan x} - \color{blue}{\log \left(e^{\frac{\sin x}{x - \tan x}}\right)}\]
    6. Applied add-log-exp0.1

      \[\leadsto \color{blue}{\log \left(e^{\frac{x}{x - \tan x}}\right)} - \log \left(e^{\frac{\sin x}{x - \tan x}}\right)\]
    7. Applied diff-log0.1

      \[\leadsto \color{blue}{\log \left(\frac{e^{\frac{x}{x - \tan x}}}{e^{\frac{\sin x}{x - \tan x}}}\right)}\]
    8. Simplified0.1

      \[\leadsto \log \color{blue}{\left(e^{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}}\right)}\]

    if -0.027836888459983777 < x < 0.02825639784178301

    1. Initial program 62.8

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

    if 0.02825639784178301 < 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.027836888459983777:\\ \;\;\;\;\log \left(e^{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}}\right)\\ \mathbf{elif}\;x \le 0.02825639784178301:\\ \;\;\;\;\left(x \cdot x\right) \cdot \frac{9}{40} - \mathsf{fma}\left(\frac{27}{2800}, \left(x \cdot x\right) \cdot \left(x \cdot x\right), \frac{1}{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \end{array}\]

Reproduce

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