Average Error: 29.4 → 0.3
Time: 4.3s
Precision: 64
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -19229.5092823207051 \lor \neg \left(x \le 63442066.521938488\right):\\ \;\;\;\;\left(\log \left(e^{\frac{-1}{{x}^{2}}}\right) - \frac{3}{x}\right) - \frac{3}{{x}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1} - \frac{{x}^{3} + {1}^{3}}{\left(1 \cdot \left(1 - x\right) + {x}^{2}\right) \cdot \left(x - 1\right)}\\ \end{array}\]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \le -19229.5092823207051 \lor \neg \left(x \le 63442066.521938488\right):\\
\;\;\;\;\left(\log \left(e^{\frac{-1}{{x}^{2}}}\right) - \frac{3}{x}\right) - \frac{3}{{x}^{3}}\\

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

\end{array}
double code(double x) {
	return ((double) (((double) (x / ((double) (x + 1.0)))) - ((double) (((double) (x + 1.0)) / ((double) (x - 1.0))))));
}
double code(double x) {
	double VAR;
	if (((x <= -19229.509282320705) || !(x <= 63442066.52193849))) {
		VAR = ((double) (((double) (((double) log(((double) exp(((double) (((double) -(1.0)) / ((double) pow(x, 2.0)))))))) - ((double) (3.0 / x)))) - ((double) (3.0 / ((double) pow(x, 3.0))))));
	} else {
		VAR = ((double) (((double) (x / ((double) (x + 1.0)))) - ((double) (((double) (((double) pow(x, 3.0)) + ((double) pow(1.0, 3.0)))) / ((double) (((double) (((double) (1.0 * ((double) (1.0 - x)))) + ((double) pow(x, 2.0)))) * ((double) (x - 1.0))))))));
	}
	return VAR;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if x < -19229.509282320705 or 63442066.52193849 < x

    1. Initial program 59.7

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

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

      \[\leadsto \color{blue}{\left(\frac{-1}{{x}^{2}} - \frac{3}{x}\right) - \frac{3}{{x}^{3}}}\]
    4. Using strategy rm
    5. Applied add-log-exp0.3

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

    if -19229.509282320705 < x < 63442066.52193849

    1. Initial program 0.2

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

      \[\leadsto \frac{x}{x + 1} - \frac{\color{blue}{\frac{{x}^{3} + {1}^{3}}{x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)}}}{x - 1}\]
    4. Applied associate-/l/0.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -19229.5092823207051 \lor \neg \left(x \le 63442066.521938488\right):\\ \;\;\;\;\left(\log \left(e^{\frac{-1}{{x}^{2}}}\right) - \frac{3}{x}\right) - \frac{3}{{x}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1} - \frac{{x}^{3} + {1}^{3}}{\left(1 \cdot \left(1 - x\right) + {x}^{2}\right) \cdot \left(x - 1\right)}\\ \end{array}\]

Reproduce

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