Average Error: 59.9 → 0.0
Time: 25.5s
Precision: 64
\[-0.0259999999999999988065102485279567190446 \lt x \land x \lt 0.0259999999999999988065102485279567190446\]
\[\frac{1}{x} - \frac{1}{\tan x}\]
\[{x}^{5} \cdot 0.002116402116402116544841005563171165704262 + \frac{x}{\frac{\frac{0.3333333333333333148296162562473909929395 - \left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027}{0.3333333333333333148296162562473909929395 + \left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027}}{0.3333333333333333148296162562473909929395 - \left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027}}\]
\frac{1}{x} - \frac{1}{\tan x}
{x}^{5} \cdot 0.002116402116402116544841005563171165704262 + \frac{x}{\frac{\frac{0.3333333333333333148296162562473909929395 - \left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027}{0.3333333333333333148296162562473909929395 + \left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027}}{0.3333333333333333148296162562473909929395 - \left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027}}
double f(double x) {
        double r3837392 = 1.0;
        double r3837393 = x;
        double r3837394 = r3837392 / r3837393;
        double r3837395 = tan(r3837393);
        double r3837396 = r3837392 / r3837395;
        double r3837397 = r3837394 - r3837396;
        return r3837397;
}

double f(double x) {
        double r3837398 = x;
        double r3837399 = 5.0;
        double r3837400 = pow(r3837398, r3837399);
        double r3837401 = 0.0021164021164021165;
        double r3837402 = r3837400 * r3837401;
        double r3837403 = 0.3333333333333333;
        double r3837404 = r3837398 * r3837398;
        double r3837405 = 0.022222222222222223;
        double r3837406 = r3837404 * r3837405;
        double r3837407 = r3837403 - r3837406;
        double r3837408 = r3837403 + r3837406;
        double r3837409 = r3837407 / r3837408;
        double r3837410 = r3837409 / r3837407;
        double r3837411 = r3837398 / r3837410;
        double r3837412 = r3837402 + r3837411;
        return r3837412;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original59.9
Target0.1
Herbie0.0
\[\begin{array}{l} \mathbf{if}\;\left|x\right| \lt 0.0259999999999999988065102485279567190446:\\ \;\;\;\;\frac{x}{3} \cdot \left(1 + \frac{x \cdot x}{15}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x} - \frac{1}{\tan x}\\ \end{array}\]

Derivation

  1. Initial program 59.9

    \[\frac{1}{x} - \frac{1}{\tan x}\]
  2. Taylor expanded around 0 0.3

    \[\leadsto \color{blue}{0.3333333333333333148296162562473909929395 \cdot x + \left(0.02222222222222222307030925492199457949027 \cdot {x}^{3} + 0.002116402116402116544841005563171165704262 \cdot {x}^{5}\right)}\]
  3. Simplified0.3

    \[\leadsto \color{blue}{x \cdot \left(0.3333333333333333148296162562473909929395 + \left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027\right) + 0.002116402116402116544841005563171165704262 \cdot {x}^{5}}\]
  4. Using strategy rm
  5. Applied flip-+0.3

    \[\leadsto x \cdot \color{blue}{\frac{0.3333333333333333148296162562473909929395 \cdot 0.3333333333333333148296162562473909929395 - \left(\left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027\right) \cdot \left(\left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027\right)}{0.3333333333333333148296162562473909929395 - \left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027}} + 0.002116402116402116544841005563171165704262 \cdot {x}^{5}\]
  6. Applied associate-*r/0.3

    \[\leadsto \color{blue}{\frac{x \cdot \left(0.3333333333333333148296162562473909929395 \cdot 0.3333333333333333148296162562473909929395 - \left(\left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027\right) \cdot \left(\left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027\right)\right)}{0.3333333333333333148296162562473909929395 - \left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027}} + 0.002116402116402116544841005563171165704262 \cdot {x}^{5}\]
  7. Using strategy rm
  8. Applied associate-/l*0.0

    \[\leadsto \color{blue}{\frac{x}{\frac{0.3333333333333333148296162562473909929395 - \left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027}{0.3333333333333333148296162562473909929395 \cdot 0.3333333333333333148296162562473909929395 - \left(\left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027\right) \cdot \left(\left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027\right)}}} + 0.002116402116402116544841005563171165704262 \cdot {x}^{5}\]
  9. Simplified0.0

    \[\leadsto \frac{x}{\color{blue}{\frac{\frac{0.3333333333333333148296162562473909929395 - \left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027}{0.3333333333333333148296162562473909929395 + \left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027}}{0.3333333333333333148296162562473909929395 - \left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027}}} + 0.002116402116402116544841005563171165704262 \cdot {x}^{5}\]
  10. Final simplification0.0

    \[\leadsto {x}^{5} \cdot 0.002116402116402116544841005563171165704262 + \frac{x}{\frac{\frac{0.3333333333333333148296162562473909929395 - \left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027}{0.3333333333333333148296162562473909929395 + \left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027}}{0.3333333333333333148296162562473909929395 - \left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027}}\]

Reproduce

herbie shell --seed 2019192 
(FPCore (x)
  :name "invcot (example 3.9)"
  :pre (and (< -0.026 x) (< x 0.026))

  :herbie-target
  (if (< (fabs x) 0.026) (* (/ x 3.0) (+ 1.0 (/ (* x x) 15.0))) (- (/ 1.0 x) (/ 1.0 (tan x))))

  (- (/ 1.0 x) (/ 1.0 (tan x))))