Average Error: 59.8 → 0.6
Time: 25.1s
Precision: 64
\[-0.0259999999999999988065102485279567190446 \lt x \land x \lt 0.0259999999999999988065102485279567190446\]
\[\frac{1}{x} - \frac{1}{\tan x}\]
\[2 \cdot \log \left(\sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}\right) + \left(3 \cdot \log \left(\sqrt[3]{\sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}}\right) + \left(0.002116402116402116544841005563171165704262 \cdot {x}^{5} + 0.3333333333333333148296162562473909929395 \cdot x\right)\right)\]
\frac{1}{x} - \frac{1}{\tan x}
2 \cdot \log \left(\sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}\right) + \left(3 \cdot \log \left(\sqrt[3]{\sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}}\right) + \left(0.002116402116402116544841005563171165704262 \cdot {x}^{5} + 0.3333333333333333148296162562473909929395 \cdot x\right)\right)
double f(double x) {
        double r83092 = 1.0;
        double r83093 = x;
        double r83094 = r83092 / r83093;
        double r83095 = tan(r83093);
        double r83096 = r83092 / r83095;
        double r83097 = r83094 - r83096;
        return r83097;
}

double f(double x) {
        double r83098 = 2.0;
        double r83099 = 0.022222222222222223;
        double r83100 = x;
        double r83101 = 3.0;
        double r83102 = pow(r83100, r83101);
        double r83103 = r83099 * r83102;
        double r83104 = exp(r83103);
        double r83105 = cbrt(r83104);
        double r83106 = log(r83105);
        double r83107 = r83098 * r83106;
        double r83108 = cbrt(r83105);
        double r83109 = log(r83108);
        double r83110 = r83101 * r83109;
        double r83111 = 0.0021164021164021165;
        double r83112 = 5.0;
        double r83113 = pow(r83100, r83112);
        double r83114 = r83111 * r83113;
        double r83115 = 0.3333333333333333;
        double r83116 = r83115 * r83100;
        double r83117 = r83114 + r83116;
        double r83118 = r83110 + r83117;
        double r83119 = r83107 + r83118;
        return r83119;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original59.8
Target0.1
Herbie0.6
\[\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.8

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

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

    \[\leadsto \color{blue}{\log \left(e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}\right)} + \left(0.002116402116402116544841005563171165704262 \cdot {x}^{5} + 0.3333333333333333148296162562473909929395 \cdot x\right)\]
  5. Using strategy rm
  6. Applied add-cube-cbrt0.6

    \[\leadsto \log \color{blue}{\left(\left(\sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}} \cdot \sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}\right) \cdot \sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}\right)} + \left(0.002116402116402116544841005563171165704262 \cdot {x}^{5} + 0.3333333333333333148296162562473909929395 \cdot x\right)\]
  7. Applied log-prod0.6

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

    \[\leadsto \left(\color{blue}{2 \cdot \log \left(\sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}\right)} + \log \left(\sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}\right)\right) + \left(0.002116402116402116544841005563171165704262 \cdot {x}^{5} + 0.3333333333333333148296162562473909929395 \cdot x\right)\]
  9. Using strategy rm
  10. Applied add-cube-cbrt0.6

    \[\leadsto \left(2 \cdot \log \left(\sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}\right) + \log \color{blue}{\left(\left(\sqrt[3]{\sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}} \cdot \sqrt[3]{\sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}}\right) \cdot \sqrt[3]{\sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}}\right)}\right) + \left(0.002116402116402116544841005563171165704262 \cdot {x}^{5} + 0.3333333333333333148296162562473909929395 \cdot x\right)\]
  11. Applied log-prod0.6

    \[\leadsto \left(2 \cdot \log \left(\sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}\right) + \color{blue}{\left(\log \left(\sqrt[3]{\sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}} \cdot \sqrt[3]{\sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}}\right) + \log \left(\sqrt[3]{\sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}}\right)\right)}\right) + \left(0.002116402116402116544841005563171165704262 \cdot {x}^{5} + 0.3333333333333333148296162562473909929395 \cdot x\right)\]
  12. Simplified0.6

    \[\leadsto \left(2 \cdot \log \left(\sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}\right) + \left(\color{blue}{2 \cdot \log \left(\sqrt[3]{\sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}}\right)} + \log \left(\sqrt[3]{\sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}}\right)\right)\right) + \left(0.002116402116402116544841005563171165704262 \cdot {x}^{5} + 0.3333333333333333148296162562473909929395 \cdot x\right)\]
  13. Final simplification0.6

    \[\leadsto 2 \cdot \log \left(\sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}\right) + \left(3 \cdot \log \left(\sqrt[3]{\sqrt[3]{e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}}}\right) + \left(0.002116402116402116544841005563171165704262 \cdot {x}^{5} + 0.3333333333333333148296162562473909929395 \cdot x\right)\right)\]

Reproduce

herbie shell --seed 2019294 
(FPCore (x)
  :name "invcot (example 3.9)"
  :precision binary64
  :pre (and (< -0.0259999999999999988 x) (< x 0.0259999999999999988))

  :herbie-target
  (if (< (fabs x) 0.0259999999999999988) (* (/ x 3) (+ 1 (/ (* x x) 15))) (- (/ 1 x) (/ 1 (tan x))))

  (- (/ 1 x) (/ 1 (tan x))))