Average Error: 29.0 → 0.3
Time: 6.7s
Precision: binary64
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \leq -23307.635529317067:\\ \;\;\;\;\frac{\frac{-12}{x \cdot x} - \left(\frac{9}{x} + \frac{48}{{x}^{3}}\right)}{\frac{x}{x + 1} \cdot \frac{x}{x + 1} + \frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1}}\\ \mathbf{elif}\;x \leq 13029.469918336774:\\ \;\;\;\;\frac{\log \left(e^{{\left(\frac{x}{x + 1}\right)}^{3} - {\left(\frac{x + 1}{x - 1}\right)}^{3}}\right)}{\frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1} + {\left(\frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}}\right)}^{4} \cdot \left(\frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}} \cdot \frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{x} \cdot \left(\frac{1}{x} + 3\right) - \frac{3}{{x}^{3}}\\ \end{array}\]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \leq -23307.635529317067:\\
\;\;\;\;\frac{\frac{-12}{x \cdot x} - \left(\frac{9}{x} + \frac{48}{{x}^{3}}\right)}{\frac{x}{x + 1} \cdot \frac{x}{x + 1} + \frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1}}\\

\mathbf{elif}\;x \leq 13029.469918336774:\\
\;\;\;\;\frac{\log \left(e^{{\left(\frac{x}{x + 1}\right)}^{3} - {\left(\frac{x + 1}{x - 1}\right)}^{3}}\right)}{\frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1} + {\left(\frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}}\right)}^{4} \cdot \left(\frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}} \cdot \frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}}\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{-1}{x} \cdot \left(\frac{1}{x} + 3\right) - \frac{3}{{x}^{3}}\\

\end{array}
(FPCore (x) :precision binary64 (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))
(FPCore (x)
 :precision binary64
 (if (<= x -23307.635529317067)
   (/
    (- (/ (- 12.0) (* x x)) (+ (/ 9.0 x) (/ 48.0 (pow x 3.0))))
    (+
     (* (/ x (+ x 1.0)) (/ x (+ x 1.0)))
     (/ (+ x (* (+ x 1.0) (/ (+ x 1.0) (- x 1.0)))) (- x 1.0))))
   (if (<= x 13029.469918336774)
     (/
      (log
       (exp (- (pow (/ x (+ x 1.0)) 3.0) (pow (/ (+ x 1.0) (- x 1.0)) 3.0))))
      (+
       (/ (+ x (* (+ x 1.0) (/ (+ x 1.0) (- x 1.0)))) (- x 1.0))
       (*
        (pow (/ (cbrt x) (cbrt (+ x 1.0))) 4.0)
        (* (/ (cbrt x) (cbrt (+ x 1.0))) (/ (cbrt x) (cbrt (+ x 1.0)))))))
     (- (* (/ -1.0 x) (+ (/ 1.0 x) 3.0)) (/ 3.0 (pow x 3.0))))))
double code(double x) {
	return ((double) ((x / ((double) (x + 1.0))) - (((double) (x + 1.0)) / ((double) (x - 1.0)))));
}
double code(double x) {
	double tmp;
	if ((x <= -23307.635529317067)) {
		tmp = (((double) ((((double) -(12.0)) / ((double) (x * x))) - ((double) ((9.0 / x) + (48.0 / ((double) pow(x, 3.0))))))) / ((double) (((double) ((x / ((double) (x + 1.0))) * (x / ((double) (x + 1.0))))) + (((double) (x + ((double) (((double) (x + 1.0)) * (((double) (x + 1.0)) / ((double) (x - 1.0))))))) / ((double) (x - 1.0))))));
	} else {
		double tmp_1;
		if ((x <= 13029.469918336774)) {
			tmp_1 = (((double) log(((double) exp(((double) (((double) pow((x / ((double) (x + 1.0))), 3.0)) - ((double) pow((((double) (x + 1.0)) / ((double) (x - 1.0))), 3.0)))))))) / ((double) ((((double) (x + ((double) (((double) (x + 1.0)) * (((double) (x + 1.0)) / ((double) (x - 1.0))))))) / ((double) (x - 1.0))) + ((double) (((double) pow((((double) cbrt(x)) / ((double) cbrt(((double) (x + 1.0))))), 4.0)) * ((double) ((((double) cbrt(x)) / ((double) cbrt(((double) (x + 1.0))))) * (((double) cbrt(x)) / ((double) cbrt(((double) (x + 1.0))))))))))));
		} else {
			tmp_1 = ((double) (((double) ((-1.0 / x) * ((double) ((1.0 / x) + 3.0)))) - (3.0 / ((double) pow(x, 3.0)))));
		}
		tmp = tmp_1;
	}
	return tmp;
}

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 < -23307.6355293170673

    1. Initial program Error: 59.4 bits

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied flip3--Error: 59.4 bits

      \[\leadsto \color{blue}{\frac{{\left(\frac{x}{x + 1}\right)}^{3} - {\left(\frac{x + 1}{x - 1}\right)}^{3}}{\frac{x}{x + 1} \cdot \frac{x}{x + 1} + \left(\frac{x + 1}{x - 1} \cdot \frac{x + 1}{x - 1} + \frac{x}{x + 1} \cdot \frac{x + 1}{x - 1}\right)}}\]
    4. SimplifiedError: 59.4 bits

      \[\leadsto \frac{{\left(\frac{x}{x + 1}\right)}^{3} - {\left(\frac{x + 1}{x - 1}\right)}^{3}}{\color{blue}{\frac{x}{x + 1} \cdot \frac{x}{x + 1} + \frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1}}}\]
    5. Taylor expanded around inf Error: 0.5 bits

      \[\leadsto \frac{\color{blue}{-\left(12 \cdot \frac{1}{{x}^{2}} + \left(9 \cdot \frac{1}{x} + 48 \cdot \frac{1}{{x}^{3}}\right)\right)}}{\frac{x}{x + 1} \cdot \frac{x}{x + 1} + \frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1}}\]
    6. SimplifiedError: 0.4 bits

      \[\leadsto \frac{\color{blue}{\frac{-12}{x \cdot x} - \left(\frac{9}{x} + \frac{48}{{x}^{3}}\right)}}{\frac{x}{x + 1} \cdot \frac{x}{x + 1} + \frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1}}\]

    if -23307.6355293170673 < x < 13029.469918336774

    1. Initial program Error: 0.1 bits

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied flip3--Error: 0.1 bits

      \[\leadsto \color{blue}{\frac{{\left(\frac{x}{x + 1}\right)}^{3} - {\left(\frac{x + 1}{x - 1}\right)}^{3}}{\frac{x}{x + 1} \cdot \frac{x}{x + 1} + \left(\frac{x + 1}{x - 1} \cdot \frac{x + 1}{x - 1} + \frac{x}{x + 1} \cdot \frac{x + 1}{x - 1}\right)}}\]
    4. SimplifiedError: 0.1 bits

      \[\leadsto \frac{{\left(\frac{x}{x + 1}\right)}^{3} - {\left(\frac{x + 1}{x - 1}\right)}^{3}}{\color{blue}{\frac{x}{x + 1} \cdot \frac{x}{x + 1} + \frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1}}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrtError: 0.1 bits

      \[\leadsto \frac{{\left(\frac{x}{x + 1}\right)}^{3} - {\left(\frac{x + 1}{x - 1}\right)}^{3}}{\frac{x}{x + 1} \cdot \frac{x}{\color{blue}{\left(\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}\right) \cdot \sqrt[3]{x + 1}}} + \frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1}}\]
    7. Applied add-cube-cbrtError: 0.1 bits

      \[\leadsto \frac{{\left(\frac{x}{x + 1}\right)}^{3} - {\left(\frac{x + 1}{x - 1}\right)}^{3}}{\frac{x}{x + 1} \cdot \frac{\color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}}}{\left(\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}\right) \cdot \sqrt[3]{x + 1}} + \frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1}}\]
    8. Applied times-fracError: 0.1 bits

      \[\leadsto \frac{{\left(\frac{x}{x + 1}\right)}^{3} - {\left(\frac{x + 1}{x - 1}\right)}^{3}}{\frac{x}{x + 1} \cdot \color{blue}{\left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}} \cdot \frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}}\right)} + \frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1}}\]
    9. Applied add-cube-cbrtError: 0.1 bits

      \[\leadsto \frac{{\left(\frac{x}{x + 1}\right)}^{3} - {\left(\frac{x + 1}{x - 1}\right)}^{3}}{\frac{x}{\color{blue}{\left(\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}\right) \cdot \sqrt[3]{x + 1}}} \cdot \left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}} \cdot \frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}}\right) + \frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1}}\]
    10. Applied add-cube-cbrtError: 0.1 bits

      \[\leadsto \frac{{\left(\frac{x}{x + 1}\right)}^{3} - {\left(\frac{x + 1}{x - 1}\right)}^{3}}{\frac{\color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}}}{\left(\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}\right) \cdot \sqrt[3]{x + 1}} \cdot \left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}} \cdot \frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}}\right) + \frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1}}\]
    11. Applied times-fracError: 0.1 bits

      \[\leadsto \frac{{\left(\frac{x}{x + 1}\right)}^{3} - {\left(\frac{x + 1}{x - 1}\right)}^{3}}{\color{blue}{\left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}} \cdot \frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}}\right)} \cdot \left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}} \cdot \frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}}\right) + \frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1}}\]
    12. Applied swap-sqrError: 0.1 bits

      \[\leadsto \frac{{\left(\frac{x}{x + 1}\right)}^{3} - {\left(\frac{x + 1}{x - 1}\right)}^{3}}{\color{blue}{\left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}} \cdot \frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}\right) \cdot \left(\frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}} \cdot \frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}}\right)} + \frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1}}\]
    13. SimplifiedError: 0.1 bits

      \[\leadsto \frac{{\left(\frac{x}{x + 1}\right)}^{3} - {\left(\frac{x + 1}{x - 1}\right)}^{3}}{\color{blue}{{\left(\frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}}\right)}^{4}} \cdot \left(\frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}} \cdot \frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}}\right) + \frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1}}\]
    14. Using strategy rm
    15. Applied add-log-expError: 0.1 bits

      \[\leadsto \frac{{\left(\frac{x}{x + 1}\right)}^{3} - \color{blue}{\log \left(e^{{\left(\frac{x + 1}{x - 1}\right)}^{3}}\right)}}{{\left(\frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}}\right)}^{4} \cdot \left(\frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}} \cdot \frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}}\right) + \frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1}}\]
    16. Applied add-log-expError: 0.2 bits

      \[\leadsto \frac{\color{blue}{\log \left(e^{{\left(\frac{x}{x + 1}\right)}^{3}}\right)} - \log \left(e^{{\left(\frac{x + 1}{x - 1}\right)}^{3}}\right)}{{\left(\frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}}\right)}^{4} \cdot \left(\frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}} \cdot \frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}}\right) + \frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1}}\]
    17. Applied diff-logError: 0.2 bits

      \[\leadsto \frac{\color{blue}{\log \left(\frac{e^{{\left(\frac{x}{x + 1}\right)}^{3}}}{e^{{\left(\frac{x + 1}{x - 1}\right)}^{3}}}\right)}}{{\left(\frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}}\right)}^{4} \cdot \left(\frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}} \cdot \frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}}\right) + \frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1}}\]
    18. SimplifiedError: 0.2 bits

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

    if 13029.469918336774 < x

    1. Initial program Error: 59.3 bits

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

      \[\leadsto \color{blue}{-\left(1 \cdot \frac{1}{{x}^{2}} + \left(3 \cdot \frac{1}{x} + 3 \cdot \frac{1}{{x}^{3}}\right)\right)}\]
    3. SimplifiedError: 0.3 bits

      \[\leadsto \color{blue}{\frac{-1}{x} \cdot \left(\frac{1}{x} + 3\right) - \frac{3}{{x}^{3}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplificationError: 0.3 bits

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -23307.635529317067:\\ \;\;\;\;\frac{\frac{-12}{x \cdot x} - \left(\frac{9}{x} + \frac{48}{{x}^{3}}\right)}{\frac{x}{x + 1} \cdot \frac{x}{x + 1} + \frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1}}\\ \mathbf{elif}\;x \leq 13029.469918336774:\\ \;\;\;\;\frac{\log \left(e^{{\left(\frac{x}{x + 1}\right)}^{3} - {\left(\frac{x + 1}{x - 1}\right)}^{3}}\right)}{\frac{x + \left(x + 1\right) \cdot \frac{x + 1}{x - 1}}{x - 1} + {\left(\frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}}\right)}^{4} \cdot \left(\frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}} \cdot \frac{\sqrt[3]{x}}{\sqrt[3]{x + 1}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{x} \cdot \left(\frac{1}{x} + 3\right) - \frac{3}{{x}^{3}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020204 
(FPCore (x)
  :name "Asymptote C"
  :precision binary64
  (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))