Average Error: 59.8 → 0.3
Time: 4.7s
Precision: 64
Internal precision: 2432
\[\frac{1}{x} - \frac{1}{\tan x}\]
\[\frac{1}{3} \cdot x + \left(\frac{1}{45} \cdot {x}^3 + \frac{2}{945} \cdot {x}^{5}\right)\]

Error

Bits error versus x

Target

Original59.8
Comparison0.1
Herbie0.3
\[ \begin{array}{l} \mathbf{if}\;\left|x\right| \lt 0.026:\\ \;\;\;\;\frac{x}{3} \cdot \left(1 + \frac{{x}^2}{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. Applied taylor 0.3

    \[\leadsto \frac{1}{45} \cdot {x}^{3} + \left(\frac{2}{945} \cdot {x}^{5} + \frac{1}{3} \cdot x\right)\]
  3. Taylor expanded around 0 0.3

    \[\leadsto \color{blue}{\frac{1}{45} \cdot {x}^{3} + \left(\frac{2}{945} \cdot {x}^{5} + \frac{1}{3} \cdot x\right)}\]
  4. Using strategy rm
  5. Applied add-cube-cbrt 1.5

    \[\leadsto \frac{1}{45} \cdot {x}^{3} + \left(\frac{2}{945} \cdot {x}^{5} + \color{blue}{{\left(\sqrt[3]{\frac{1}{3} \cdot x}\right)}^3}\right)\]
  6. Applied taylor 35.0

    \[\leadsto \frac{1}{45} \cdot {x}^{3} + \left(\frac{2}{945} \cdot {x}^{5} + {\left(e^{\frac{1}{3} \cdot \left(\log \frac{1}{3} + \log x\right)}\right)}^3\right)\]
  7. Taylor expanded around 0 35.0

    \[\leadsto \frac{1}{45} \cdot {x}^{3} + \left(\frac{2}{945} \cdot {x}^{5} + {\color{blue}{\left(e^{\frac{1}{3} \cdot \left(\log \frac{1}{3} + \log x\right)}\right)}}^3\right)\]
  8. Applied simplify 0.3

    \[\leadsto \color{blue}{\frac{1}{3} \cdot x + \left(\left(x \cdot \frac{1}{45}\right) \cdot {x}^2 + \frac{2}{945} \cdot {x}^{5}\right)}\]
  9. Applied simplify 0.3

    \[\leadsto \frac{1}{3} \cdot x + \color{blue}{\left(\frac{1}{45} \cdot {x}^3 + \frac{2}{945} \cdot {x}^{5}\right)}\]
  10. Removed slow pow expressions

Runtime

Time bar (total: 4.7s) Debug logProfile

Please include this information when filing a bug report:

herbie shell --seed '#(1064524629 4159152179 2999149171 575749698 4006532819 692958815)'
(FPCore (x)
  :name "invcot (example 3.9)"
  :pre (and (< -0.026 x) (< x 0.026))

  :target
  (if (< (fabs x) 0.026) (* (/ x 3) (+ 1 (/ (sqr x) 15))) (- (/ 1 x) (/ 1 (tan x))))

  (- (/ 1 x) (/ 1 (tan x))))