Average Error: 59.8 → 0.3
Time: 14.5s
Precision: 64
\[-0.0259999999999999988 \lt x \land x \lt 0.0259999999999999988\]
\[\frac{1}{x} - \frac{1}{\tan x}\]
\[\left(0.0222222222222222231 \cdot {x}^{3} + 0.00211640211640211654 \cdot {x}^{5}\right) + 0.333333333333333315 \cdot x\]
\frac{1}{x} - \frac{1}{\tan x}
\left(0.0222222222222222231 \cdot {x}^{3} + 0.00211640211640211654 \cdot {x}^{5}\right) + 0.333333333333333315 \cdot x
double f(double x) {
        double r124738 = 1.0;
        double r124739 = x;
        double r124740 = r124738 / r124739;
        double r124741 = tan(r124739);
        double r124742 = r124738 / r124741;
        double r124743 = r124740 - r124742;
        return r124743;
}

double f(double x) {
        double r124744 = 0.022222222222222223;
        double r124745 = x;
        double r124746 = 3.0;
        double r124747 = pow(r124745, r124746);
        double r124748 = r124744 * r124747;
        double r124749 = 0.0021164021164021165;
        double r124750 = 5.0;
        double r124751 = pow(r124745, r124750);
        double r124752 = r124749 * r124751;
        double r124753 = r124748 + r124752;
        double r124754 = 0.3333333333333333;
        double r124755 = r124754 * r124745;
        double r124756 = r124753 + r124755;
        return r124756;
}

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.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 59.8

    \[\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. Using strategy rm
  4. Applied associate-+r+0.3

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

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

Reproduce

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