Average Error: 31.5 → 0.0
Time: 28.0s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.029332414347062297:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.030132695111622844:\\ \;\;\;\;\left(\frac{9}{40} - \frac{27}{2800} \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right) - \frac{1}{2}\\ \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.029332414347062297:\\
\;\;\;\;\frac{x - \sin x}{x - \tan x}\\

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

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

\end{array}
double f(double x) {
        double r363952 = x;
        double r363953 = sin(r363952);
        double r363954 = r363952 - r363953;
        double r363955 = tan(r363952);
        double r363956 = r363952 - r363955;
        double r363957 = r363954 / r363956;
        return r363957;
}

double f(double x) {
        double r363958 = x;
        double r363959 = -0.029332414347062297;
        bool r363960 = r363958 <= r363959;
        double r363961 = sin(r363958);
        double r363962 = r363958 - r363961;
        double r363963 = tan(r363958);
        double r363964 = r363958 - r363963;
        double r363965 = r363962 / r363964;
        double r363966 = 0.030132695111622844;
        bool r363967 = r363958 <= r363966;
        double r363968 = 0.225;
        double r363969 = 0.009642857142857142;
        double r363970 = r363958 * r363958;
        double r363971 = r363969 * r363970;
        double r363972 = r363968 - r363971;
        double r363973 = r363972 * r363970;
        double r363974 = 0.5;
        double r363975 = r363973 - r363974;
        double r363976 = r363967 ? r363975 : r363965;
        double r363977 = r363960 ? r363965 : r363976;
        return r363977;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if x < -0.029332414347062297 or 0.030132695111622844 < x

    1. Initial program 0.0

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

      \[\leadsto \frac{\color{blue}{x - \sin x}}{x - \tan x}\]

    if -0.029332414347062297 < x < 0.030132695111622844

    1. Initial program 62.8

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

      \[\leadsto \frac{\color{blue}{x - \sin x}}{x - \tan x}\]
    3. 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)}\]
    4. Simplified0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.029332414347062297:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.030132695111622844:\\ \;\;\;\;\left(\frac{9}{40} - \frac{27}{2800} \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right) - \frac{1}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \end{array}\]

Reproduce

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