Average Error: 30.5 → 0.5
Time: 20.3s
Precision: 64
Internal precision: 2432
\[\frac{1}{x} - \frac{1}{\tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -6.667433711053936 \cdot 10^{-08}:\\ \;\;\;\;\frac{1}{x} - \frac{1}{\tan x}\\ \mathbf{if}\;x \le 1183236732512159.2:\\ \;\;\;\;\frac{1}{45} \cdot {x}^{3} + \left(\frac{2}{945} \cdot {x}^{5} + \frac{1}{3} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x} - \frac{1}{\tan x}\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes.
  2. if x < -6.667433711053936e-08 or 1183236732512159.2 < x

    1. Initial program 0.6

      \[\frac{1}{x} - \frac{1}{\tan x}\]

    if -6.667433711053936e-08 < x < 1183236732512159.2

    1. Initial program 60.1

      \[\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)}\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions

Runtime

Time bar (total: 20.3s) Debug log

Please include this information when filing a bug report:

herbie shell --seed '#(3052192724 3812927732 3686175817 630908657 2373248591 511094450)'
(FPCore (x)
  :name "NMSE example 3.9"
  :pre (!= x 0)
  (- (/ 1 x) (/ 1 (tan x))))