Average Error: 59.8 → 0.4
Time: 9.9s
Precision: binary64
\[-0.0259999999999999988 \lt x \land x \lt 0.0259999999999999988\]
\[\frac{1}{x} - \frac{1}{\tan x}\]
\[\frac{1 \cdot \left(0.66666666666666663 \cdot 0.66666666666666663 - \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right) \cdot \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right)\right)}{\left(\frac{1}{x} + \frac{1}{\tan x}\right) \cdot \left(0.66666666666666663 + \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right)\right)}\]
\frac{1}{x} - \frac{1}{\tan x}
\frac{1 \cdot \left(0.66666666666666663 \cdot 0.66666666666666663 - \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right) \cdot \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right)\right)}{\left(\frac{1}{x} + \frac{1}{\tan x}\right) \cdot \left(0.66666666666666663 + \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right)\right)}
double code(double x) {
	return ((double) (((double) (1.0 / x)) - ((double) (1.0 / ((double) tan(x))))));
}
double code(double x) {
	return ((double) (((double) (1.0 * ((double) (((double) (0.6666666666666666 * 0.6666666666666666)) - ((double) (((double) (((double) (x * ((double) (x * 0.06666666666666667)))) + ((double) (((double) pow(x, 4.0)) * 0.010582010582010581)))) * ((double) (((double) (x * ((double) (x * 0.06666666666666667)))) + ((double) (((double) pow(x, 4.0)) * 0.010582010582010581)))))))))) / ((double) (((double) (((double) (1.0 / x)) + ((double) (1.0 / ((double) tan(x)))))) * ((double) (0.6666666666666666 + ((double) (((double) (x * ((double) (x * 0.06666666666666667)))) + ((double) (((double) pow(x, 4.0)) * 0.010582010582010581))))))))));
}

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.4
\[\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. Using strategy rm
  3. Applied flip--62.1

    \[\leadsto \color{blue}{\frac{\frac{1}{x} \cdot \frac{1}{x} - \frac{1}{\tan x} \cdot \frac{1}{\tan x}}{\frac{1}{x} + \frac{1}{\tan x}}}\]
  4. Simplified62.1

    \[\leadsto \frac{\color{blue}{1 \cdot \left(\frac{1}{x \cdot x} - \frac{1}{\tan x \cdot \tan x}\right)}}{\frac{1}{x} + \frac{1}{\tan x}}\]
  5. Taylor expanded around 0 0.4

    \[\leadsto \frac{1 \cdot \color{blue}{\left(0.66666666666666663 - \left(0.0666666666666666657 \cdot {x}^{2} + 0.01058201058201058 \cdot {x}^{4}\right)\right)}}{\frac{1}{x} + \frac{1}{\tan x}}\]
  6. Simplified0.4

    \[\leadsto \frac{1 \cdot \color{blue}{\left(0.66666666666666663 - \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right)\right)}}{\frac{1}{x} + \frac{1}{\tan x}}\]
  7. Using strategy rm
  8. Applied flip--0.4

    \[\leadsto \frac{1 \cdot \color{blue}{\frac{0.66666666666666663 \cdot 0.66666666666666663 - \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right) \cdot \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right)}{0.66666666666666663 + \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right)}}}{\frac{1}{x} + \frac{1}{\tan x}}\]
  9. Applied associate-*r/0.4

    \[\leadsto \frac{\color{blue}{\frac{1 \cdot \left(0.66666666666666663 \cdot 0.66666666666666663 - \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right) \cdot \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right)\right)}{0.66666666666666663 + \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right)}}}{\frac{1}{x} + \frac{1}{\tan x}}\]
  10. Applied associate-/l/0.4

    \[\leadsto \color{blue}{\frac{1 \cdot \left(0.66666666666666663 \cdot 0.66666666666666663 - \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right) \cdot \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right)\right)}{\left(\frac{1}{x} + \frac{1}{\tan x}\right) \cdot \left(0.66666666666666663 + \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right)\right)}}\]
  11. Final simplification0.4

    \[\leadsto \frac{1 \cdot \left(0.66666666666666663 \cdot 0.66666666666666663 - \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right) \cdot \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right)\right)}{\left(\frac{1}{x} + \frac{1}{\tan x}\right) \cdot \left(0.66666666666666663 + \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right)\right)}\]

Reproduce

herbie shell --seed 2020184 
(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.0) (+ 1.0 (/ (* x x) 15.0))) (- (/ 1.0 x) (/ 1.0 (tan x))))

  (- (/ 1.0 x) (/ 1.0 (tan x))))