Average Error: 59.9 → 0.4
Time: 48.2s
Precision: 64
Internal Precision: 2368
\[\frac{1}{x} - \frac{1}{\tan x}\]
\[(\left(\sqrt{(\left(x \cdot x\right) \cdot \frac{1}{45} + \frac{1}{3})_*} \cdot \sqrt{(\left(x \cdot x\right) \cdot \frac{1}{45} + \frac{1}{3})_*}\right) \cdot x + \left(\log \left(e^{\frac{2}{945} \cdot {x}^{5}}\right)\right))_*\]

Error

Bits error versus x

Target

Original59.9
Target0.1
Herbie0.4
\[\begin{array}{l} \mathbf{if}\;\left|x\right| \lt 0.026:\\ \;\;\;\;\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.9

    \[\frac{1}{x} - \frac{1}{\tan x}\]
  2. Taylor expanded around 0 0.4

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

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

    \[\leadsto (\left((\left(x \cdot x\right) \cdot \frac{1}{45} + \frac{1}{3})_*\right) \cdot x + \color{blue}{\left(\log \left(e^{\frac{2}{945} \cdot {x}^{5}}\right)\right)})_*\]
  6. Using strategy rm
  7. Applied add-sqr-sqrt0.4

    \[\leadsto (\color{blue}{\left(\sqrt{(\left(x \cdot x\right) \cdot \frac{1}{45} + \frac{1}{3})_*} \cdot \sqrt{(\left(x \cdot x\right) \cdot \frac{1}{45} + \frac{1}{3})_*}\right)} \cdot x + \left(\log \left(e^{\frac{2}{945} \cdot {x}^{5}}\right)\right))_*\]

Runtime

Time bar (total: 48.2s)Debug logProfile

herbie shell --seed '#(1072967564 1937075727 894099792 790700740 1036514779 1027793188)' +o rules:numerics
(FPCore (x)
  :name "invcot (example 3.9)"
  :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))))