Average Error: 28.7 → 0.3
Time: 23.0s
Precision: 64
Internal Precision: 1408
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;(\left(1 + \frac{3}{x}\right) \cdot \left(\frac{-1}{x \cdot x}\right) + \left(\frac{-3}{x}\right))_* \le -4.242258952429771 \cdot 10^{-13}:\\ \;\;\;\;\frac{x}{x + 1} - \frac{\sqrt{x + 1}}{\frac{x - 1}{\sqrt{x + 1}}}\\ \mathbf{if}\;(\left(1 + \frac{3}{x}\right) \cdot \left(\frac{-1}{x \cdot x}\right) + \left(\frac{-3}{x}\right))_* \le 2.98938586655047 \cdot 10^{-11}:\\ \;\;\;\;(\left(1 + \frac{3}{x}\right) \cdot \left(\frac{-1}{x \cdot x}\right) + \left(\frac{-3}{x}\right))_*\\ \mathbf{else}:\\ \;\;\;\;(x \cdot \left(\frac{1}{x + 1}\right) + \left(-\frac{x + 1}{x - 1}\right))_*\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 3 regimes
  2. if (fma (+ 1 (/ 3 x)) (/ (- 1) (* x x)) (/ (- 3) x)) < -4.242258952429771e-13

    1. Initial program 0.6

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.6

      \[\leadsto \frac{x}{x + 1} - \frac{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}{x - 1}\]
    4. Applied associate-/l*0.6

      \[\leadsto \frac{x}{x + 1} - \color{blue}{\frac{\sqrt{x + 1}}{\frac{x - 1}{\sqrt{x + 1}}}}\]

    if -4.242258952429771e-13 < (fma (+ 1 (/ 3 x)) (/ (- 1) (* x x)) (/ (- 3) x)) < 2.98938586655047e-11

    1. Initial program 60.2

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

      \[\leadsto \color{blue}{-\left(3 \cdot \frac{1}{{x}^{3}} + \left(3 \cdot \frac{1}{x} + \frac{1}{{x}^{2}}\right)\right)}\]
    3. Applied simplify0.0

      \[\leadsto \color{blue}{(\left(1 + \frac{3}{x}\right) \cdot \left(\frac{-1}{x \cdot x}\right) + \left(\frac{-3}{x}\right))_*}\]

    if 2.98938586655047e-11 < (fma (+ 1 (/ 3 x)) (/ (- 1) (* x x)) (/ (- 3) x))

    1. Initial program 0.5

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied div-inv0.5

      \[\leadsto \color{blue}{x \cdot \frac{1}{x + 1}} - \frac{x + 1}{x - 1}\]
    4. Applied fma-neg0.5

      \[\leadsto \color{blue}{(x \cdot \left(\frac{1}{x + 1}\right) + \left(-\frac{x + 1}{x - 1}\right))_*}\]
  3. Recombined 3 regimes into one program.

Runtime

Time bar (total: 23.0s)Debug logProfile

herbie shell --seed '#(1070355188 2193211668 3977393919 3454156579 3755371326 1656365382)' +o rules:numerics
(FPCore (x)
  :name "Asymptote C"
  (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))