Average Error: 29.2 → 0.1
Time: 52.1s
Precision: 64
Internal Precision: 1408
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;\frac{-3}{x} - \frac{1 + \frac{3}{x}}{x \cdot x} \le -5.1867978784335024 \cdot 10^{-08}:\\ \;\;\;\;x \cdot \frac{1}{x + 1} - \frac{x + 1}{x - 1}\\ \mathbf{if}\;\frac{-3}{x} - \frac{1 + \frac{3}{x}}{x \cdot x} \le 1.3033902556442452 \cdot 10^{-06}:\\ \;\;\;\;\frac{-3}{x} - \frac{1 + \frac{3}{x}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\log \left(\sqrt{e^{\frac{x}{1 + x} - \frac{1 + x}{x - 1}}} \cdot \sqrt{e^{\frac{x}{1 + x} - \frac{1 + x}{x - 1}}}\right)\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 3 regimes
  2. if (- (/ (- 3) x) (/ (+ 1 (/ 3 x)) (* x x))) < -5.1867978784335024e-08

    1. Initial program 0.3

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

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

    if -5.1867978784335024e-08 < (- (/ (- 3) x) (/ (+ 1 (/ 3 x)) (* x x))) < 1.3033902556442452e-06

    1. Initial program 59.6

      \[\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}{\frac{-3}{x} - \frac{1 + \frac{3}{x}}{x \cdot x}}\]

    if 1.3033902556442452e-06 < (- (/ (- 3) x) (/ (+ 1 (/ 3 x)) (* x x)))

    1. Initial program 0.2

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied add-log-exp0.2

      \[\leadsto \frac{x}{x + 1} - \color{blue}{\log \left(e^{\frac{x + 1}{x - 1}}\right)}\]
    4. Applied add-log-exp0.2

      \[\leadsto \color{blue}{\log \left(e^{\frac{x}{x + 1}}\right)} - \log \left(e^{\frac{x + 1}{x - 1}}\right)\]
    5. Applied diff-log0.2

      \[\leadsto \color{blue}{\log \left(\frac{e^{\frac{x}{x + 1}}}{e^{\frac{x + 1}{x - 1}}}\right)}\]
    6. Applied simplify0.2

      \[\leadsto \log \color{blue}{\left(e^{\frac{x}{1 + x} - \frac{1 + x}{x - 1}}\right)}\]
    7. Using strategy rm
    8. Applied add-sqr-sqrt0.2

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

Runtime

Time bar (total: 52.1s)Debug logProfile

herbie shell --seed '#(1070578969 3140398606 632207097 462683394 1189254563 964980650)' 
(FPCore (x)
  :name "Asymptote C"
  (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))