Average Error: 60.0 → 0.0
Time: 23.7s
Precision: 64
\[-0.026 \lt x \land x \lt 0.026\]
\[\frac{1}{x} - \frac{1}{\tan x}\]
\[\log \left(e^{{x}^{5} \cdot \frac{2}{945}}\right) + \frac{x}{\frac{\frac{\frac{1}{3} - \frac{1}{45} \cdot \left(x \cdot x\right)}{\frac{1}{3} + \frac{1}{45} \cdot \left(x \cdot x\right)}}{\frac{1}{3} - \frac{1}{45} \cdot \left(x \cdot x\right)}}\]
\frac{1}{x} - \frac{1}{\tan x}
\log \left(e^{{x}^{5} \cdot \frac{2}{945}}\right) + \frac{x}{\frac{\frac{\frac{1}{3} - \frac{1}{45} \cdot \left(x \cdot x\right)}{\frac{1}{3} + \frac{1}{45} \cdot \left(x \cdot x\right)}}{\frac{1}{3} - \frac{1}{45} \cdot \left(x \cdot x\right)}}
double f(double x) {
        double r1249132 = 1.0;
        double r1249133 = x;
        double r1249134 = r1249132 / r1249133;
        double r1249135 = tan(r1249133);
        double r1249136 = r1249132 / r1249135;
        double r1249137 = r1249134 - r1249136;
        return r1249137;
}

double f(double x) {
        double r1249138 = x;
        double r1249139 = 5.0;
        double r1249140 = pow(r1249138, r1249139);
        double r1249141 = 0.0021164021164021165;
        double r1249142 = r1249140 * r1249141;
        double r1249143 = exp(r1249142);
        double r1249144 = log(r1249143);
        double r1249145 = 0.3333333333333333;
        double r1249146 = 0.022222222222222223;
        double r1249147 = r1249138 * r1249138;
        double r1249148 = r1249146 * r1249147;
        double r1249149 = r1249145 - r1249148;
        double r1249150 = r1249145 + r1249148;
        double r1249151 = r1249149 / r1249150;
        double r1249152 = r1249151 / r1249149;
        double r1249153 = r1249138 / r1249152;
        double r1249154 = r1249144 + r1249153;
        return r1249154;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original60.0
Target0.1
Herbie0.0
\[\begin{array}{l} \mathbf{if}\;\left|x\right| \lt 0.026:\\ \;\;\;\;\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 60.0

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

    \[\leadsto \color{blue}{\frac{1}{3} \cdot x + \left(\frac{1}{45} \cdot {x}^{3} + \frac{2}{945} \cdot {x}^{5}\right)}\]
  3. Simplified0.4

    \[\leadsto \color{blue}{{x}^{5} \cdot \frac{2}{945} + x \cdot \left(\frac{1}{3} + \frac{1}{45} \cdot \left(x \cdot x\right)\right)}\]
  4. Using strategy rm
  5. Applied flip-+0.4

    \[\leadsto {x}^{5} \cdot \frac{2}{945} + x \cdot \color{blue}{\frac{\frac{1}{3} \cdot \frac{1}{3} - \left(\frac{1}{45} \cdot \left(x \cdot x\right)\right) \cdot \left(\frac{1}{45} \cdot \left(x \cdot x\right)\right)}{\frac{1}{3} - \frac{1}{45} \cdot \left(x \cdot x\right)}}\]
  6. Applied associate-*r/0.3

    \[\leadsto {x}^{5} \cdot \frac{2}{945} + \color{blue}{\frac{x \cdot \left(\frac{1}{3} \cdot \frac{1}{3} - \left(\frac{1}{45} \cdot \left(x \cdot x\right)\right) \cdot \left(\frac{1}{45} \cdot \left(x \cdot x\right)\right)\right)}{\frac{1}{3} - \frac{1}{45} \cdot \left(x \cdot x\right)}}\]
  7. Using strategy rm
  8. Applied associate-/l*0.0

    \[\leadsto {x}^{5} \cdot \frac{2}{945} + \color{blue}{\frac{x}{\frac{\frac{1}{3} - \frac{1}{45} \cdot \left(x \cdot x\right)}{\frac{1}{3} \cdot \frac{1}{3} - \left(\frac{1}{45} \cdot \left(x \cdot x\right)\right) \cdot \left(\frac{1}{45} \cdot \left(x \cdot x\right)\right)}}}\]
  9. Simplified0.0

    \[\leadsto {x}^{5} \cdot \frac{2}{945} + \frac{x}{\color{blue}{\frac{\frac{\frac{1}{3} - \left(x \cdot x\right) \cdot \frac{1}{45}}{\left(x \cdot x\right) \cdot \frac{1}{45} + \frac{1}{3}}}{\frac{1}{3} - \left(x \cdot x\right) \cdot \frac{1}{45}}}}\]
  10. Using strategy rm
  11. Applied add-log-exp0.0

    \[\leadsto \color{blue}{\log \left(e^{{x}^{5} \cdot \frac{2}{945}}\right)} + \frac{x}{\frac{\frac{\frac{1}{3} - \left(x \cdot x\right) \cdot \frac{1}{45}}{\left(x \cdot x\right) \cdot \frac{1}{45} + \frac{1}{3}}}{\frac{1}{3} - \left(x \cdot x\right) \cdot \frac{1}{45}}}\]
  12. Final simplification0.0

    \[\leadsto \log \left(e^{{x}^{5} \cdot \frac{2}{945}}\right) + \frac{x}{\frac{\frac{\frac{1}{3} - \frac{1}{45} \cdot \left(x \cdot x\right)}{\frac{1}{3} + \frac{1}{45} \cdot \left(x \cdot x\right)}}{\frac{1}{3} - \frac{1}{45} \cdot \left(x \cdot x\right)}}\]

Reproduce

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

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

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