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

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

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

\end{array}
double f(double x) {
        double r1902626 = x;
        double r1902627 = sin(r1902626);
        double r1902628 = r1902626 - r1902627;
        double r1902629 = tan(r1902626);
        double r1902630 = r1902626 - r1902629;
        double r1902631 = r1902628 / r1902630;
        return r1902631;
}

double f(double x) {
        double r1902632 = x;
        double r1902633 = -2.447149999215354;
        bool r1902634 = r1902632 <= r1902633;
        double r1902635 = sin(r1902632);
        double r1902636 = r1902632 * r1902632;
        double r1902637 = r1902635 / r1902636;
        double r1902638 = cos(r1902632);
        double r1902639 = r1902638 * r1902638;
        double r1902640 = r1902635 / r1902639;
        double r1902641 = r1902638 * r1902632;
        double r1902642 = r1902635 / r1902641;
        double r1902643 = r1902635 / r1902638;
        double r1902644 = r1902635 / r1902632;
        double r1902645 = fma(r1902637, r1902643, r1902644);
        double r1902646 = r1902642 - r1902645;
        double r1902647 = fma(r1902637, r1902640, r1902646);
        double r1902648 = 1.0;
        double r1902649 = r1902647 + r1902648;
        double r1902650 = 2.424239464461981;
        bool r1902651 = r1902632 <= r1902650;
        double r1902652 = 0.225;
        double r1902653 = 0.009642857142857142;
        double r1902654 = r1902636 * r1902653;
        double r1902655 = r1902652 - r1902654;
        double r1902656 = -0.5;
        double r1902657 = fma(r1902636, r1902655, r1902656);
        double r1902658 = r1902651 ? r1902657 : r1902649;
        double r1902659 = r1902634 ? r1902649 : r1902658;
        return r1902659;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -2.447149999215354 or 2.424239464461981 < x

    1. Initial program 0.0

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

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

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

    if -2.447149999215354 < x < 2.424239464461981

    1. Initial program 62.8

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt61.2

      \[\leadsto \frac{x - \sin x}{x - \color{blue}{\left(\sqrt[3]{\tan x} \cdot \sqrt[3]{\tan x}\right) \cdot \sqrt[3]{\tan x}}}\]
    4. Applied add-cube-cbrt62.9

      \[\leadsto \frac{x - \sin x}{\color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}} - \left(\sqrt[3]{\tan x} \cdot \sqrt[3]{\tan x}\right) \cdot \sqrt[3]{\tan x}}\]
    5. Applied prod-diff62.9

      \[\leadsto \frac{x - \sin x}{\color{blue}{\mathsf{fma}\left(\sqrt[3]{x} \cdot \sqrt[3]{x}, \sqrt[3]{x}, -\sqrt[3]{\tan x} \cdot \left(\sqrt[3]{\tan x} \cdot \sqrt[3]{\tan x}\right)\right) + \mathsf{fma}\left(-\sqrt[3]{\tan x}, \sqrt[3]{\tan x} \cdot \sqrt[3]{\tan x}, \sqrt[3]{\tan x} \cdot \left(\sqrt[3]{\tan x} \cdot \sqrt[3]{\tan x}\right)\right)}}\]
    6. Simplified61.0

      \[\leadsto \frac{x - \sin x}{\color{blue}{\left(\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x} - \tan x\right)} + \mathsf{fma}\left(-\sqrt[3]{\tan x}, \sqrt[3]{\tan x} \cdot \sqrt[3]{\tan x}, \sqrt[3]{\tan x} \cdot \left(\sqrt[3]{\tan x} \cdot \sqrt[3]{\tan x}\right)\right)}\]
    7. Simplified61.3

      \[\leadsto \frac{x - \sin x}{\left(\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x} - \tan x\right) + \color{blue}{\tan x \cdot 0}}\]
    8. Taylor expanded around 0 0.2

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x \cdot x, \frac{9}{40} - \left(x \cdot x\right) \cdot \frac{27}{2800}, \frac{-1}{2}\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

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

Reproduce

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