Average Error: 59.9 → 0.0
Time: 24.7s
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 r3414845 = 1.0;
        double r3414846 = x;
        double r3414847 = r3414845 / r3414846;
        double r3414848 = tan(r3414846);
        double r3414849 = r3414845 / r3414848;
        double r3414850 = r3414847 - r3414849;
        return r3414850;
}

double f(double x) {
        double r3414851 = x;
        double r3414852 = 5.0;
        double r3414853 = pow(r3414851, r3414852);
        double r3414854 = 0.0021164021164021165;
        double r3414855 = r3414853 * r3414854;
        double r3414856 = 0.3333333333333333;
        double r3414857 = r3414851 * r3414851;
        double r3414858 = 0.022222222222222223;
        double r3414859 = r3414857 * r3414858;
        double r3414860 = r3414856 - r3414859;
        double r3414861 = r3414856 + r3414859;
        double r3414862 = r3414860 / r3414861;
        double r3414863 = r3414862 / r3414860;
        double r3414864 = r3414851 / r3414863;
        double r3414865 = r3414855 + r3414864;
        return r3414865;
}

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 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))))