Average Error: 29.9 → 0.3
Time: 5.8s
Precision: binary64
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1} \]
\[\begin{array}{l} t_0 := \frac{-1}{{x}^{2}} - 3 \cdot \frac{1}{x}\\ t_1 := \frac{x}{x + 1} - \frac{x + 1}{x - 1}\\ \mathbf{if}\;x \leq -422691.3719611488:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 339755.70170894644:\\ \;\;\;\;\frac{{\left(\sqrt[3]{\log \left(e^{t_1}\right)}\right)}^{2}}{\frac{1}{\sqrt[3]{t_1}}}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
t_0 := \frac{-1}{{x}^{2}} - 3 \cdot \frac{1}{x}\\
t_1 := \frac{x}{x + 1} - \frac{x + 1}{x - 1}\\
\mathbf{if}\;x \leq -422691.3719611488:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 339755.70170894644:\\
\;\;\;\;\frac{{\left(\sqrt[3]{\log \left(e^{t_1}\right)}\right)}^{2}}{\frac{1}{\sqrt[3]{t_1}}}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
(FPCore (x) :precision binary64 (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (- (/ -1.0 (pow x 2.0)) (* 3.0 (/ 1.0 x))))
        (t_1 (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0)))))
   (if (<= x -422691.3719611488)
     t_0
     (if (<= x 339755.70170894644)
       (/ (pow (cbrt (log (exp t_1))) 2.0) (/ 1.0 (cbrt t_1)))
       t_0))))
double code(double x) {
	return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
double code(double x) {
	double t_0 = (-1.0 / pow(x, 2.0)) - (3.0 * (1.0 / x));
	double t_1 = (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
	double tmp;
	if (x <= -422691.3719611488) {
		tmp = t_0;
	} else if (x <= 339755.70170894644) {
		tmp = pow(cbrt(log(exp(t_1))), 2.0) / (1.0 / cbrt(t_1));
	} else {
		tmp = t_0;
	}
	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 2 regimes
  2. if x < -422691.3719611488 or 339755.701708946435 < x

    1. Initial program 59.4

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

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

    if -422691.3719611488 < x < 339755.701708946435

    1. Initial program 0.1

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1} \]
    2. Applied egg-rr0.2

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{x}{x + 1} - \frac{x + 1}{x - 1}}\right)}^{3}} \]
    3. Applied egg-rr0.2

      \[\leadsto {\color{blue}{\left(\frac{\sqrt[3]{{\left(\frac{x}{x + 1}\right)}^{2} - {\left(\frac{x + 1}{x - 1}\right)}^{2}}}{\sqrt[3]{\frac{x}{x + 1} + \frac{x + 1}{x - 1}}}\right)}}^{3} \]
    4. Applied egg-rr0.2

      \[\leadsto \color{blue}{\frac{{\left(\sqrt[3]{\frac{x}{x + 1} - \frac{x + 1}{x - 1}}\right)}^{2}}{\frac{1}{\sqrt[3]{\frac{x}{x + 1} - \frac{x + 1}{x - 1}}}}} \]
    5. Applied egg-rr0.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -422691.3719611488:\\ \;\;\;\;\frac{-1}{{x}^{2}} - 3 \cdot \frac{1}{x}\\ \mathbf{elif}\;x \leq 339755.70170894644:\\ \;\;\;\;\frac{{\left(\sqrt[3]{\log \left(e^{\frac{x}{x + 1} - \frac{x + 1}{x - 1}}\right)}\right)}^{2}}{\frac{1}{\sqrt[3]{\frac{x}{x + 1} - \frac{x + 1}{x - 1}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{{x}^{2}} - 3 \cdot \frac{1}{x}\\ \end{array} \]

Reproduce

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