Average Error: 31.2 → 0.0
Time: 4.2m
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.031885889845860715:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.02792484771501168:\\ \;\;\;\;(\left(x \cdot x\right) \cdot \frac{9}{40} + \left((\frac{-27}{2800} \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) + \frac{-1}{2})_*\right))_*\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{(\left(\sqrt{x}\right) \cdot \left(\frac{\sqrt{x}}{x - \tan x}\right) + \left(-\frac{\sin x}{x - \tan x}\right))_* \cdot \left((\left(\sqrt{x}\right) \cdot \left(\frac{\sqrt{x}}{x - \tan x}\right) + \left(-\frac{\sin x}{x - \tan x}\right))_* \cdot (\left(\sqrt{x}\right) \cdot \left(\frac{\sqrt{x}}{x - \tan x}\right) + \left(-\frac{\sin x}{x - \tan x}\right))_*\right)}\\ \end{array}\]
double f(double x) {
        double r7553920 = x;
        double r7553921 = sin(r7553920);
        double r7553922 = r7553920 - r7553921;
        double r7553923 = tan(r7553920);
        double r7553924 = r7553920 - r7553923;
        double r7553925 = r7553922 / r7553924;
        return r7553925;
}

double f(double x) {
        double r7553926 = x;
        double r7553927 = -0.031885889845860715;
        bool r7553928 = r7553926 <= r7553927;
        double r7553929 = tan(r7553926);
        double r7553930 = r7553926 - r7553929;
        double r7553931 = r7553926 / r7553930;
        double r7553932 = sin(r7553926);
        double r7553933 = r7553932 / r7553930;
        double r7553934 = r7553931 - r7553933;
        double r7553935 = 0.02792484771501168;
        bool r7553936 = r7553926 <= r7553935;
        double r7553937 = r7553926 * r7553926;
        double r7553938 = 0.225;
        double r7553939 = -0.009642857142857142;
        double r7553940 = r7553937 * r7553937;
        double r7553941 = -0.5;
        double r7553942 = fma(r7553939, r7553940, r7553941);
        double r7553943 = fma(r7553937, r7553938, r7553942);
        double r7553944 = sqrt(r7553926);
        double r7553945 = r7553944 / r7553930;
        double r7553946 = -r7553933;
        double r7553947 = fma(r7553944, r7553945, r7553946);
        double r7553948 = r7553947 * r7553947;
        double r7553949 = r7553947 * r7553948;
        double r7553950 = cbrt(r7553949);
        double r7553951 = r7553936 ? r7553943 : r7553950;
        double r7553952 = r7553928 ? r7553934 : r7553951;
        return r7553952;
}

\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
\mathbf{if}\;x \le -0.031885889845860715:\\
\;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\

\mathbf{elif}\;x \le 0.02792484771501168:\\
\;\;\;\;(\left(x \cdot x\right) \cdot \frac{9}{40} + \left((\frac{-27}{2800} \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) + \frac{-1}{2})_*\right))_*\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{(\left(\sqrt{x}\right) \cdot \left(\frac{\sqrt{x}}{x - \tan x}\right) + \left(-\frac{\sin x}{x - \tan x}\right))_* \cdot \left((\left(\sqrt{x}\right) \cdot \left(\frac{\sqrt{x}}{x - \tan x}\right) + \left(-\frac{\sin x}{x - \tan x}\right))_* \cdot (\left(\sqrt{x}\right) \cdot \left(\frac{\sqrt{x}}{x - \tan x}\right) + \left(-\frac{\sin x}{x - \tan x}\right))_*\right)}\\

\end{array}

Error

Bits error versus x

Derivation

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

    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.031885889845860715 < x < 0.02792484771501168

    1. Initial program 62.7

      \[\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}{(\left(x \cdot x\right) \cdot \frac{9}{40} + \left((\frac{-27}{2800} \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) + \frac{-1}{2})_*\right))_*}\]

    if 0.02792484771501168 < x

    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 *-un-lft-identity0.1

      \[\leadsto \frac{x}{x - \color{blue}{1 \cdot \tan x}} - \frac{\sin x}{x - \tan x}\]
    6. Applied *-un-lft-identity0.1

      \[\leadsto \frac{x}{\color{blue}{1 \cdot x} - 1 \cdot \tan x} - \frac{\sin x}{x - \tan x}\]
    7. Applied distribute-lft-out--0.1

      \[\leadsto \frac{x}{\color{blue}{1 \cdot \left(x - \tan x\right)}} - \frac{\sin x}{x - \tan x}\]
    8. Applied add-sqr-sqrt0.6

      \[\leadsto \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{1 \cdot \left(x - \tan x\right)} - \frac{\sin x}{x - \tan x}\]
    9. Applied times-frac0.6

      \[\leadsto \color{blue}{\frac{\sqrt{x}}{1} \cdot \frac{\sqrt{x}}{x - \tan x}} - \frac{\sin x}{x - \tan x}\]
    10. Applied fma-neg0.6

      \[\leadsto \color{blue}{(\left(\frac{\sqrt{x}}{1}\right) \cdot \left(\frac{\sqrt{x}}{x - \tan x}\right) + \left(-\frac{\sin x}{x - \tan x}\right))_*}\]
    11. Simplified0.6

      \[\leadsto (\color{blue}{\left(\sqrt{x}\right)} \cdot \left(\frac{\sqrt{x}}{x - \tan x}\right) + \left(-\frac{\sin x}{x - \tan x}\right))_*\]
    12. Using strategy rm
    13. Applied add-cbrt-cube0.1

      \[\leadsto \color{blue}{\sqrt[3]{\left((\left(\sqrt{x}\right) \cdot \left(\frac{\sqrt{x}}{x - \tan x}\right) + \left(-\frac{\sin x}{x - \tan x}\right))_* \cdot (\left(\sqrt{x}\right) \cdot \left(\frac{\sqrt{x}}{x - \tan x}\right) + \left(-\frac{\sin x}{x - \tan x}\right))_*\right) \cdot (\left(\sqrt{x}\right) \cdot \left(\frac{\sqrt{x}}{x - \tan x}\right) + \left(-\frac{\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.031885889845860715:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.02792484771501168:\\ \;\;\;\;(\left(x \cdot x\right) \cdot \frac{9}{40} + \left((\frac{-27}{2800} \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) + \frac{-1}{2})_*\right))_*\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{(\left(\sqrt{x}\right) \cdot \left(\frac{\sqrt{x}}{x - \tan x}\right) + \left(-\frac{\sin x}{x - \tan x}\right))_* \cdot \left((\left(\sqrt{x}\right) \cdot \left(\frac{\sqrt{x}}{x - \tan x}\right) + \left(-\frac{\sin x}{x - \tan x}\right))_* \cdot (\left(\sqrt{x}\right) \cdot \left(\frac{\sqrt{x}}{x - \tan x}\right) + \left(-\frac{\sin x}{x - \tan x}\right))_*\right)}\\ \end{array}\]

Reproduce

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