Average Error: 29.8 → 0.4
Time: 32.9s
Precision: 64
Internal Precision: 2368
\[\frac{1}{x} - \frac{1}{\tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.025270672509866966:\\ \;\;\;\;\frac{\tan x - x}{x \cdot \tan x}\\ \mathbf{if}\;x \le 0.02649457116105631:\\ \;\;\;\;\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{\cos x}{\sin x}\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if x < -0.025270672509866966

    1. Initial program 0.3

      \[\frac{1}{x} - \frac{1}{\tan x}\]
    2. Using strategy rm
    3. Applied frac-sub0.4

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

      \[\leadsto \frac{\color{blue}{\tan x - x}}{x \cdot \tan x}\]

    if -0.025270672509866966 < x < 0.02649457116105631

    1. Initial program 59.8

      \[\frac{1}{x} - \frac{1}{\tan x}\]
    2. 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)}\]

    if 0.02649457116105631 < x

    1. Initial program 0.3

      \[\frac{1}{x} - \frac{1}{\tan x}\]
    2. Taylor expanded around inf 0.3

      \[\leadsto \color{blue}{\frac{1}{x} - \frac{\cos x}{\sin x}}\]
  3. Recombined 3 regimes into one program.

Runtime

Time bar (total: 32.9s)Debug log

herbie shell --seed '#(2775764126 3555076145 3898259844 1891440260 2599947619 1948460636)' 
(FPCore (x)
  :name "1/x-1/tan(x)"
  (- (/ 1 x) (/ 1 (tan x))))