Average Error: 60.0 → 0.5
Time: 19.1s
Precision: 64
\[-0.0259999999999999988065102485279567190446 \lt x \land x \lt 0.0259999999999999988065102485279567190446\]
\[\frac{1}{x} - \frac{1}{\tan x}\]
\[\log \left(e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}\right) + \left(\log \left(e^{0.002116402116402116544841005563171165704262 \cdot {x}^{5}}\right) + 0.3333333333333333148296162562473909929395 \cdot x\right)\]
\frac{1}{x} - \frac{1}{\tan x}
\log \left(e^{0.02222222222222222307030925492199457949027 \cdot {x}^{3}}\right) + \left(\log \left(e^{0.002116402116402116544841005563171165704262 \cdot {x}^{5}}\right) + 0.3333333333333333148296162562473909929395 \cdot x\right)
double f(double x) {
        double r78377 = 1.0;
        double r78378 = x;
        double r78379 = r78377 / r78378;
        double r78380 = tan(r78378);
        double r78381 = r78377 / r78380;
        double r78382 = r78379 - r78381;
        return r78382;
}

double f(double x) {
        double r78383 = 0.022222222222222223;
        double r78384 = x;
        double r78385 = 3.0;
        double r78386 = pow(r78384, r78385);
        double r78387 = r78383 * r78386;
        double r78388 = exp(r78387);
        double r78389 = log(r78388);
        double r78390 = 0.0021164021164021165;
        double r78391 = 5.0;
        double r78392 = pow(r78384, r78391);
        double r78393 = r78390 * r78392;
        double r78394 = exp(r78393);
        double r78395 = log(r78394);
        double r78396 = 0.3333333333333333;
        double r78397 = r78396 * r78384;
        double r78398 = r78395 + r78397;
        double r78399 = r78389 + r78398;
        return r78399;
}

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.5
\[\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 60.0

    \[\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. 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-log-exp0.5

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

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

Reproduce

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