Average Error: 28.9 → 0.5
Time: 5.6m
Precision: 64
Internal Precision: 1344
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;\sqrt[3]{{\left((\left(1 + \frac{3}{x}\right) \cdot \left(\frac{-1}{x \cdot x}\right) + \left(\frac{-3}{x}\right))_*\right)}^{3}} \le -0.01091010827941926:\\ \;\;\;\;\log \left(\sqrt{e^{\frac{x}{1 + x} - \frac{1 + x}{x - 1}}}\right) + \log \left(\sqrt{e^{\frac{x}{1 + x} - \frac{1 + x}{x - 1}}}\right)\\ \mathbf{if}\;\sqrt[3]{{\left((\left(1 + \frac{3}{x}\right) \cdot \left(\frac{-1}{x \cdot x}\right) + \left(\frac{-3}{x}\right))_*\right)}^{3}} \le 8.323236187655386 \cdot 10^{+18}:\\ \;\;\;\;(\left(1 + \frac{3}{x}\right) \cdot \left(\frac{-1}{x \cdot x}\right) + \left(-\frac{3}{x}\right))_*\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt[3]{\frac{x}{x + 1}} \cdot \sqrt[3]{\frac{x}{x + 1}}\right) \cdot \sqrt[3]{\frac{x}{x + 1}} - \frac{x + 1}{x - 1}\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 3 regimes
  2. if (cbrt (pow (fma (+ 1 (/ 3 x)) (/ (- 1) (* x x)) (/ (- 3) x)) 3)) < -0.01091010827941926

    1. Initial program 0.0

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

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

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

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

      \[\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.0

      \[\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)}\]
    9. Applied log-prod0.0

      \[\leadsto \color{blue}{\log \left(\sqrt{e^{\frac{x}{1 + x} - \frac{1 + x}{x - 1}}}\right) + \log \left(\sqrt{e^{\frac{x}{1 + x} - \frac{1 + x}{x - 1}}}\right)}\]

    if -0.01091010827941926 < (cbrt (pow (fma (+ 1 (/ 3 x)) (/ (- 1) (* x x)) (/ (- 3) x)) 3)) < 8.323236187655386e+18

    1. Initial program 58.3

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

      \[\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.9

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

    if 8.323236187655386e+18 < (cbrt (pow (fma (+ 1 (/ 3 x)) (/ (- 1) (* x x)) (/ (- 3) x)) 3))

    1. Initial program 0.0

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt0.0

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

Runtime

Time bar (total: 5.6m)Debug logProfile

herbie shell --seed '#(1071215679 2002590028 935158157 1944352234 2656991306 2955288481)' +o rules:numerics
(FPCore (x)
  :name "Asymptote C"
  (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))