Average Error: 59.8 → 0.3
Time: 19.1s
Precision: 64
\[-0.0259999999999999988065102485279567190446 \lt x \land x \lt 0.0259999999999999988065102485279567190446\]
\[\frac{1}{x} - \frac{1}{\tan x}\]
\[\left(\frac{6405119470038039}{288230376151711744} \cdot {x}^{3} + \frac{4880091024790887}{2305843009213693952} \cdot {x}^{5}\right) + \frac{6004799503160661}{18014398509481984} \cdot x\]
\frac{1}{x} - \frac{1}{\tan x}
\left(\frac{6405119470038039}{288230376151711744} \cdot {x}^{3} + \frac{4880091024790887}{2305843009213693952} \cdot {x}^{5}\right) + \frac{6004799503160661}{18014398509481984} \cdot x
double f(double x) {
        double r57640 = 1.0;
        double r57641 = x;
        double r57642 = r57640 / r57641;
        double r57643 = tan(r57641);
        double r57644 = r57640 / r57643;
        double r57645 = r57642 - r57644;
        return r57645;
}

double f(double x) {
        double r57646 = 6405119470038039.0;
        double r57647 = 2.8823037615171174e+17;
        double r57648 = r57646 / r57647;
        double r57649 = x;
        double r57650 = 3.0;
        double r57651 = pow(r57649, r57650);
        double r57652 = r57648 * r57651;
        double r57653 = 4880091024790887.0;
        double r57654 = 2.305843009213694e+18;
        double r57655 = r57653 / r57654;
        double r57656 = 5.0;
        double r57657 = pow(r57649, r57656);
        double r57658 = r57655 * r57657;
        double r57659 = r57652 + r57658;
        double r57660 = 6004799503160661.0;
        double r57661 = 18014398509481984.0;
        double r57662 = r57660 / r57661;
        double r57663 = r57662 * r57649;
        double r57664 = r57659 + r57663;
        return r57664;
}

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

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

    \[\leadsto \color{blue}{\frac{6405119470038039}{288230376151711744} \cdot {x}^{3} + \left(\frac{4880091024790887}{2305843009213693952} \cdot {x}^{5} + \frac{6004799503160661}{18014398509481984} \cdot x\right)}\]
  4. Using strategy rm
  5. Applied add-log-exp0.4

    \[\leadsto \frac{6405119470038039}{288230376151711744} \cdot {x}^{3} + \left(\color{blue}{\log \left(e^{\frac{4880091024790887}{2305843009213693952} \cdot {x}^{5}}\right)} + \frac{6004799503160661}{18014398509481984} \cdot x\right)\]
  6. Final simplification0.3

    \[\leadsto \left(\frac{6405119470038039}{288230376151711744} \cdot {x}^{3} + \frac{4880091024790887}{2305843009213693952} \cdot {x}^{5}\right) + \frac{6004799503160661}{18014398509481984} \cdot x\]

Reproduce

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