Average Error: 32.3 → 0.2
Time: 37.1s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.444222751025642903499601743533276021481:\\ \;\;\;\;\left(\frac{\frac{\sin x}{\cos x}}{x} - \mathsf{fma}\left(\frac{\sin x}{\cos x}, \frac{\sin x}{x \cdot x}, \frac{\sin x}{x}\right)\right) + \left(1 + \frac{\frac{\sin x}{\cos x}}{x} \cdot \frac{\frac{\sin x}{\cos x}}{x}\right)\\ \mathbf{elif}\;x \le 1.587340532796493342004851001547649502754:\\ \;\;\;\;\mathsf{fma}\left(\frac{9}{40}, x \cdot x, \frac{-1}{2}\right) - \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{27}{2800}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}} \cdot \sqrt{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}}\\ \end{array}\]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
\mathbf{if}\;x \le -2.444222751025642903499601743533276021481:\\
\;\;\;\;\left(\frac{\frac{\sin x}{\cos x}}{x} - \mathsf{fma}\left(\frac{\sin x}{\cos x}, \frac{\sin x}{x \cdot x}, \frac{\sin x}{x}\right)\right) + \left(1 + \frac{\frac{\sin x}{\cos x}}{x} \cdot \frac{\frac{\sin x}{\cos x}}{x}\right)\\

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

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

\end{array}
double f(double x) {
        double r874598 = x;
        double r874599 = sin(r874598);
        double r874600 = r874598 - r874599;
        double r874601 = tan(r874598);
        double r874602 = r874598 - r874601;
        double r874603 = r874600 / r874602;
        return r874603;
}

double f(double x) {
        double r874604 = x;
        double r874605 = -2.444222751025643;
        bool r874606 = r874604 <= r874605;
        double r874607 = sin(r874604);
        double r874608 = cos(r874604);
        double r874609 = r874607 / r874608;
        double r874610 = r874609 / r874604;
        double r874611 = r874604 * r874604;
        double r874612 = r874607 / r874611;
        double r874613 = r874607 / r874604;
        double r874614 = fma(r874609, r874612, r874613);
        double r874615 = r874610 - r874614;
        double r874616 = 1.0;
        double r874617 = r874610 * r874610;
        double r874618 = r874616 + r874617;
        double r874619 = r874615 + r874618;
        double r874620 = 1.5873405327964933;
        bool r874621 = r874604 <= r874620;
        double r874622 = 0.225;
        double r874623 = -0.5;
        double r874624 = fma(r874622, r874611, r874623);
        double r874625 = 0.009642857142857142;
        double r874626 = r874611 * r874625;
        double r874627 = r874611 * r874626;
        double r874628 = r874624 - r874627;
        double r874629 = tan(r874604);
        double r874630 = r874604 - r874629;
        double r874631 = r874604 / r874630;
        double r874632 = r874607 / r874630;
        double r874633 = r874631 - r874632;
        double r874634 = sqrt(r874633);
        double r874635 = r874634 * r874634;
        double r874636 = r874621 ? r874628 : r874635;
        double r874637 = r874606 ? r874619 : r874636;
        return r874637;
}

Error

Bits error versus x

Derivation

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

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Taylor expanded around inf 0.5

      \[\leadsto \color{blue}{\left(1 + \left(\frac{{\left(\sin x\right)}^{2}}{{\left(\cos x\right)}^{2} \cdot {x}^{2}} + \frac{\sin x}{\cos x \cdot x}\right)\right) - \left(\frac{\sin x}{x} + \frac{{\left(\sin x\right)}^{2}}{\cos x \cdot {x}^{2}}\right)}\]
    3. Simplified0.5

      \[\leadsto \color{blue}{\left(1 + \frac{\frac{\sin x}{\cos x}}{x} \cdot \frac{\frac{\sin x}{\cos x}}{x}\right) + \left(\frac{\frac{\sin x}{\cos x}}{x} - \mathsf{fma}\left(\frac{\sin x}{\cos x}, \frac{\sin x}{x \cdot x}, \frac{\sin x}{x}\right)\right)}\]

    if -2.444222751025643 < x < 1.5873405327964933

    1. Initial program 63.0

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Taylor expanded around 0 0.1

      \[\leadsto \color{blue}{\frac{9}{40} \cdot {x}^{2} - \left(\frac{27}{2800} \cdot {x}^{4} + \frac{1}{2}\right)}\]
    3. Simplified0.1

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{9}{40}, x \cdot x, \frac{-1}{2}\right) - \left(\frac{27}{2800} \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)}\]

    if 1.5873405327964933 < 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 add-sqr-sqrt0.0

      \[\leadsto \color{blue}{\sqrt{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}} \cdot \sqrt{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.444222751025642903499601743533276021481:\\ \;\;\;\;\left(\frac{\frac{\sin x}{\cos x}}{x} - \mathsf{fma}\left(\frac{\sin x}{\cos x}, \frac{\sin x}{x \cdot x}, \frac{\sin x}{x}\right)\right) + \left(1 + \frac{\frac{\sin x}{\cos x}}{x} \cdot \frac{\frac{\sin x}{\cos x}}{x}\right)\\ \mathbf{elif}\;x \le 1.587340532796493342004851001547649502754:\\ \;\;\;\;\mathsf{fma}\left(\frac{9}{40}, x \cdot x, \frac{-1}{2}\right) - \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{27}{2800}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}} \cdot \sqrt{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}}\\ \end{array}\]

Reproduce

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