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

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

\mathbf{else}:\\
\;\;\;\;\frac{{\left(\frac{x}{x - \tan x}\right)}^{3} - {\left(\frac{\sin x}{x - \tan x}\right)}^{3}}{\mathsf{fma}\left(\frac{x}{x - \tan x}, \frac{x}{x - \tan x}, \frac{\sin x}{x - \tan x} \cdot \left(\frac{x}{x - \tan x} + \frac{\sin x}{x - \tan x}\right)\right)}\\

\end{array}
double f(double x) {
        double r26635 = x;
        double r26636 = sin(r26635);
        double r26637 = r26635 - r26636;
        double r26638 = tan(r26635);
        double r26639 = r26635 - r26638;
        double r26640 = r26637 / r26639;
        return r26640;
}

double f(double x) {
        double r26641 = x;
        double r26642 = -0.02915897731694385;
        bool r26643 = r26641 <= r26642;
        double r26644 = tan(r26641);
        double r26645 = r26641 - r26644;
        double r26646 = r26641 / r26645;
        double r26647 = sin(r26641);
        double r26648 = r26647 / r26645;
        double r26649 = r26646 - r26648;
        double r26650 = exp(r26649);
        double r26651 = log(r26650);
        double r26652 = 0.028578832745905277;
        bool r26653 = r26641 <= r26652;
        double r26654 = 0.225;
        double r26655 = 2.0;
        double r26656 = pow(r26641, r26655);
        double r26657 = r26654 * r26656;
        double r26658 = 0.009642857142857142;
        double r26659 = 4.0;
        double r26660 = pow(r26641, r26659);
        double r26661 = 0.5;
        double r26662 = fma(r26658, r26660, r26661);
        double r26663 = r26657 - r26662;
        double r26664 = 3.0;
        double r26665 = pow(r26646, r26664);
        double r26666 = pow(r26648, r26664);
        double r26667 = r26665 - r26666;
        double r26668 = r26646 + r26648;
        double r26669 = r26648 * r26668;
        double r26670 = fma(r26646, r26646, r26669);
        double r26671 = r26667 / r26670;
        double r26672 = r26653 ? r26663 : r26671;
        double r26673 = r26643 ? r26651 : r26672;
        return r26673;
}

Error

Bits error versus x

Derivation

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

    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.2

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

      \[\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.2

      \[\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.02915897731694385 < x < 0.028578832745905277

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

    if 0.028578832745905277 < x

    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}}\]
    4. Using strategy rm
    5. Applied flip3--0.0

      \[\leadsto \color{blue}{\frac{{\left(\frac{x}{x - \tan x}\right)}^{3} - {\left(\frac{\sin x}{x - \tan x}\right)}^{3}}{\frac{x}{x - \tan x} \cdot \frac{x}{x - \tan x} + \left(\frac{\sin x}{x - \tan x} \cdot \frac{\sin x}{x - \tan x} + \frac{x}{x - \tan x} \cdot \frac{\sin x}{x - \tan x}\right)}}\]
    6. Simplified0.0

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

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

Reproduce

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