Average Error: 60.0 → 0.3
Time: 12.1s
Precision: 64
\[-0.0259999999999999988 \lt x \land x \lt 0.0259999999999999988\]
\[\frac{1}{x} - \frac{1}{\tan x}\]
\[0.0222222222222222231 \cdot {x}^{3} + \left(0.00211640211640211654 \cdot {x}^{5} + 0.333333333333333315 \cdot x\right)\]
\frac{1}{x} - \frac{1}{\tan x}
0.0222222222222222231 \cdot {x}^{3} + \left(0.00211640211640211654 \cdot {x}^{5} + 0.333333333333333315 \cdot x\right)
double f(double x) {
        double r106556 = 1.0;
        double r106557 = x;
        double r106558 = r106556 / r106557;
        double r106559 = tan(r106557);
        double r106560 = r106556 / r106559;
        double r106561 = r106558 - r106560;
        return r106561;
}

double f(double x) {
        double r106562 = 0.022222222222222223;
        double r106563 = x;
        double r106564 = 3.0;
        double r106565 = pow(r106563, r106564);
        double r106566 = r106562 * r106565;
        double r106567 = 0.0021164021164021165;
        double r106568 = 5.0;
        double r106569 = pow(r106563, r106568);
        double r106570 = r106567 * r106569;
        double r106571 = 0.3333333333333333;
        double r106572 = r106571 * r106563;
        double r106573 = r106570 + r106572;
        double r106574 = r106566 + r106573;
        return r106574;
}

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.3
\[\begin{array}{l} \mathbf{if}\;\left|x\right| \lt 0.0259999999999999988:\\ \;\;\;\;\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.3

    \[\leadsto \color{blue}{0.0222222222222222231 \cdot {x}^{3} + \left(0.00211640211640211654 \cdot {x}^{5} + 0.333333333333333315 \cdot x\right)}\]
  3. Final simplification0.3

    \[\leadsto 0.0222222222222222231 \cdot {x}^{3} + \left(0.00211640211640211654 \cdot {x}^{5} + 0.333333333333333315 \cdot x\right)\]

Reproduce

herbie shell --seed 2020018 
(FPCore (x)
  :name "invcot (example 3.9)"
  :precision binary64
  :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))))