Average Error: 59.9 → 0.0
Time: 27.4s
Precision: 64
\[-0.0259999999999999988065102485279567190446 \lt x \land x \lt 0.0259999999999999988065102485279567190446\]
\[\frac{1}{x} - \frac{1}{\tan x}\]
\[0.002116402116402116544841005563171165704262 \cdot {x}^{5} + \frac{x}{\frac{1}{\left(0.02222222222222222307030925492199457949027 \cdot x\right) \cdot x - 0.3333333333333333148296162562473909929395}} \cdot \frac{1}{\frac{\left(0.02222222222222222307030925492199457949027 \cdot x\right) \cdot x - 0.3333333333333333148296162562473909929395}{0.3333333333333333148296162562473909929395 + \left(0.02222222222222222307030925492199457949027 \cdot x\right) \cdot x}}\]
\frac{1}{x} - \frac{1}{\tan x}
0.002116402116402116544841005563171165704262 \cdot {x}^{5} + \frac{x}{\frac{1}{\left(0.02222222222222222307030925492199457949027 \cdot x\right) \cdot x - 0.3333333333333333148296162562473909929395}} \cdot \frac{1}{\frac{\left(0.02222222222222222307030925492199457949027 \cdot x\right) \cdot x - 0.3333333333333333148296162562473909929395}{0.3333333333333333148296162562473909929395 + \left(0.02222222222222222307030925492199457949027 \cdot x\right) \cdot x}}
double f(double x) {
        double r5029432 = 1.0;
        double r5029433 = x;
        double r5029434 = r5029432 / r5029433;
        double r5029435 = tan(r5029433);
        double r5029436 = r5029432 / r5029435;
        double r5029437 = r5029434 - r5029436;
        return r5029437;
}

double f(double x) {
        double r5029438 = 0.0021164021164021165;
        double r5029439 = x;
        double r5029440 = 5.0;
        double r5029441 = pow(r5029439, r5029440);
        double r5029442 = r5029438 * r5029441;
        double r5029443 = 1.0;
        double r5029444 = 0.022222222222222223;
        double r5029445 = r5029444 * r5029439;
        double r5029446 = r5029445 * r5029439;
        double r5029447 = 0.3333333333333333;
        double r5029448 = r5029446 - r5029447;
        double r5029449 = r5029443 / r5029448;
        double r5029450 = r5029439 / r5029449;
        double r5029451 = r5029447 + r5029446;
        double r5029452 = r5029448 / r5029451;
        double r5029453 = r5029443 / r5029452;
        double r5029454 = r5029450 * r5029453;
        double r5029455 = r5029442 + r5029454;
        return r5029455;
}

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(\left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027 + 0.3333333333333333148296162562473909929395\right) + 0.002116402116402116544841005563171165704262 \cdot {x}^{5}}\]
  4. Using strategy rm
  5. Applied flip-+0.3

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

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

    \[\leadsto \color{blue}{\frac{x}{\frac{\left(x \cdot x\right) \cdot 0.02222222222222222307030925492199457949027 - 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 \cdot 0.3333333333333333148296162562473909929395}}} + 0.002116402116402116544841005563171165704262 \cdot {x}^{5}\]
  9. Simplified0.0

    \[\leadsto \frac{x}{\color{blue}{\frac{\frac{x \cdot \left(x \cdot 0.02222222222222222307030925492199457949027\right) - 0.3333333333333333148296162562473909929395}{x \cdot \left(x \cdot 0.02222222222222222307030925492199457949027\right) + 0.3333333333333333148296162562473909929395}}{x \cdot \left(x \cdot 0.02222222222222222307030925492199457949027\right) - 0.3333333333333333148296162562473909929395}}} + 0.002116402116402116544841005563171165704262 \cdot {x}^{5}\]
  10. Using strategy rm
  11. Applied div-inv0.0

    \[\leadsto \frac{x}{\color{blue}{\frac{x \cdot \left(x \cdot 0.02222222222222222307030925492199457949027\right) - 0.3333333333333333148296162562473909929395}{x \cdot \left(x \cdot 0.02222222222222222307030925492199457949027\right) + 0.3333333333333333148296162562473909929395} \cdot \frac{1}{x \cdot \left(x \cdot 0.02222222222222222307030925492199457949027\right) - 0.3333333333333333148296162562473909929395}}} + 0.002116402116402116544841005563171165704262 \cdot {x}^{5}\]
  12. Applied *-un-lft-identity0.0

    \[\leadsto \frac{\color{blue}{1 \cdot x}}{\frac{x \cdot \left(x \cdot 0.02222222222222222307030925492199457949027\right) - 0.3333333333333333148296162562473909929395}{x \cdot \left(x \cdot 0.02222222222222222307030925492199457949027\right) + 0.3333333333333333148296162562473909929395} \cdot \frac{1}{x \cdot \left(x \cdot 0.02222222222222222307030925492199457949027\right) - 0.3333333333333333148296162562473909929395}} + 0.002116402116402116544841005563171165704262 \cdot {x}^{5}\]
  13. Applied times-frac0.0

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

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

Reproduce

herbie shell --seed 2019171 
(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))))