Average Error: 29.7 → 0.3
Time: 11.4s
Precision: binary64
Cost: 8708
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1} \]
\[\begin{array}{l} \mathbf{if}\;\frac{x}{x + 1} - \frac{x + 1}{x + -1} \leq 10^{-10}:\\ \;\;\;\;\frac{\left(3 + \frac{2}{x \cdot x}\right) - \left(\frac{2}{x} + \frac{2}{{x}^{3}}\right)}{\frac{x + -1}{-1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x + -1}{x + 1} - \frac{x + 1}{x}}{1 + \frac{-1}{x}}\\ \end{array} \]
(FPCore (x) :precision binary64 (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))
(FPCore (x)
 :precision binary64
 (if (<= (- (/ x (+ x 1.0)) (/ (+ x 1.0) (+ x -1.0))) 1e-10)
   (/
    (- (+ 3.0 (/ 2.0 (* x x))) (+ (/ 2.0 x) (/ 2.0 (pow x 3.0))))
    (/ (+ x -1.0) -1.0))
   (/ (- (/ (+ x -1.0) (+ x 1.0)) (/ (+ x 1.0) x)) (+ 1.0 (/ -1.0 x)))))
double code(double x) {
	return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
double code(double x) {
	double tmp;
	if (((x / (x + 1.0)) - ((x + 1.0) / (x + -1.0))) <= 1e-10) {
		tmp = ((3.0 + (2.0 / (x * x))) - ((2.0 / x) + (2.0 / pow(x, 3.0)))) / ((x + -1.0) / -1.0);
	} else {
		tmp = (((x + -1.0) / (x + 1.0)) - ((x + 1.0) / x)) / (1.0 + (-1.0 / x));
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (x / (x + 1.0d0)) - ((x + 1.0d0) / (x - 1.0d0))
end function
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (((x / (x + 1.0d0)) - ((x + 1.0d0) / (x + (-1.0d0)))) <= 1d-10) then
        tmp = ((3.0d0 + (2.0d0 / (x * x))) - ((2.0d0 / x) + (2.0d0 / (x ** 3.0d0)))) / ((x + (-1.0d0)) / (-1.0d0))
    else
        tmp = (((x + (-1.0d0)) / (x + 1.0d0)) - ((x + 1.0d0) / x)) / (1.0d0 + ((-1.0d0) / x))
    end if
    code = tmp
end function
public static double code(double x) {
	return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
public static double code(double x) {
	double tmp;
	if (((x / (x + 1.0)) - ((x + 1.0) / (x + -1.0))) <= 1e-10) {
		tmp = ((3.0 + (2.0 / (x * x))) - ((2.0 / x) + (2.0 / Math.pow(x, 3.0)))) / ((x + -1.0) / -1.0);
	} else {
		tmp = (((x + -1.0) / (x + 1.0)) - ((x + 1.0) / x)) / (1.0 + (-1.0 / x));
	}
	return tmp;
}
def code(x):
	return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))
def code(x):
	tmp = 0
	if ((x / (x + 1.0)) - ((x + 1.0) / (x + -1.0))) <= 1e-10:
		tmp = ((3.0 + (2.0 / (x * x))) - ((2.0 / x) + (2.0 / math.pow(x, 3.0)))) / ((x + -1.0) / -1.0)
	else:
		tmp = (((x + -1.0) / (x + 1.0)) - ((x + 1.0) / x)) / (1.0 + (-1.0 / x))
	return tmp
function code(x)
	return Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x - 1.0)))
end
function code(x)
	tmp = 0.0
	if (Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x + -1.0))) <= 1e-10)
		tmp = Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(x * x))) - Float64(Float64(2.0 / x) + Float64(2.0 / (x ^ 3.0)))) / Float64(Float64(x + -1.0) / -1.0));
	else
		tmp = Float64(Float64(Float64(Float64(x + -1.0) / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / x)) / Float64(1.0 + Float64(-1.0 / x)));
	end
	return tmp
end
function tmp = code(x)
	tmp = (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (((x / (x + 1.0)) - ((x + 1.0) / (x + -1.0))) <= 1e-10)
		tmp = ((3.0 + (2.0 / (x * x))) - ((2.0 / x) + (2.0 / (x ^ 3.0)))) / ((x + -1.0) / -1.0);
	else
		tmp = (((x + -1.0) / (x + 1.0)) - ((x + 1.0) / x)) / (1.0 + (-1.0 / x));
	end
	tmp_2 = tmp;
end
code[x_] := N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 1.0), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-10], N[(N[(N[(3.0 + N[(2.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(2.0 / x), $MachinePrecision] + N[(2.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x + -1.0), $MachinePrecision] / -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(x + -1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
\mathbf{if}\;\frac{x}{x + 1} - \frac{x + 1}{x + -1} \leq 10^{-10}:\\
\;\;\;\;\frac{\left(3 + \frac{2}{x \cdot x}\right) - \left(\frac{2}{x} + \frac{2}{{x}^{3}}\right)}{\frac{x + -1}{-1}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{x + -1}{x + 1} - \frac{x + 1}{x}}{1 + \frac{-1}{x}}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 1.00000000000000004e-10

    1. Initial program 59.4

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-x, \frac{x + -1}{x + 1}, -\mathsf{fma}\left(-1, x, -1\right) \cdot 1\right)}{\mathsf{fma}\left(-1, x, -1\right) \cdot \frac{x + -1}{x + 1}}} \]
    3. Simplified58.8

      \[\leadsto \color{blue}{\frac{\left(1 + x\right) - \frac{x}{\frac{1 + x}{x + -1}}}{\frac{x + -1}{-1}}} \]
      Proof
      (/.f64 (-.f64 (+.f64 1 x) (/.f64 x (/.f64 (+.f64 1 x) (+.f64 x -1)))) (/.f64 (+.f64 x -1) -1)): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (Rewrite<= +-commutative_binary64 (+.f64 x 1)) (/.f64 x (/.f64 (+.f64 1 x) (+.f64 x -1)))) (/.f64 (+.f64 x -1) -1)): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (+.f64 x 1) (/.f64 x (/.f64 (Rewrite<= +-commutative_binary64 (+.f64 x 1)) (+.f64 x -1)))) (/.f64 (+.f64 x -1) -1)): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (+.f64 x 1) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 x (+.f64 x -1)) (+.f64 x 1)))) (/.f64 (+.f64 x -1) -1)): 84 points increase in error, 1 points decrease in error
      (/.f64 (-.f64 (+.f64 x 1) (Rewrite<= associate-*r/_binary64 (*.f64 x (/.f64 (+.f64 x -1) (+.f64 x 1))))) (/.f64 (+.f64 x -1) -1)): 1 points increase in error, 83 points decrease in error
      (/.f64 (Rewrite<= unsub-neg_binary64 (+.f64 (+.f64 x 1) (neg.f64 (*.f64 x (/.f64 (+.f64 x -1) (+.f64 x 1)))))) (/.f64 (+.f64 x -1) -1)): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (Rewrite<= remove-double-neg_binary64 (neg.f64 (neg.f64 (+.f64 x 1)))) (neg.f64 (*.f64 x (/.f64 (+.f64 x -1) (+.f64 x 1))))) (/.f64 (+.f64 x -1) -1)): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (neg.f64 (Rewrite=> distribute-neg-in_binary64 (+.f64 (neg.f64 x) (neg.f64 1)))) (neg.f64 (*.f64 x (/.f64 (+.f64 x -1) (+.f64 x 1))))) (/.f64 (+.f64 x -1) -1)): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (neg.f64 (+.f64 (Rewrite=> neg-mul-1_binary64 (*.f64 -1 x)) (neg.f64 1))) (neg.f64 (*.f64 x (/.f64 (+.f64 x -1) (+.f64 x 1))))) (/.f64 (+.f64 x -1) -1)): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (neg.f64 (+.f64 (*.f64 -1 x) (Rewrite=> metadata-eval -1))) (neg.f64 (*.f64 x (/.f64 (+.f64 x -1) (+.f64 x 1))))) (/.f64 (+.f64 x -1) -1)): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (neg.f64 (Rewrite<= fma-udef_binary64 (fma.f64 -1 x -1))) (neg.f64 (*.f64 x (/.f64 (+.f64 x -1) (+.f64 x 1))))) (/.f64 (+.f64 x -1) -1)): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (neg.f64 (Rewrite<= *-rgt-identity_binary64 (*.f64 (fma.f64 -1 x -1) 1))) (neg.f64 (*.f64 x (/.f64 (+.f64 x -1) (+.f64 x 1))))) (/.f64 (+.f64 x -1) -1)): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (neg.f64 (*.f64 (fma.f64 -1 x -1) 1)) (Rewrite<= distribute-lft-neg-out_binary64 (*.f64 (neg.f64 x) (/.f64 (+.f64 x -1) (+.f64 x 1))))) (/.f64 (+.f64 x -1) -1)): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 (neg.f64 x) (/.f64 (+.f64 x -1) (+.f64 x 1))) (neg.f64 (*.f64 (fma.f64 -1 x -1) 1)))) (/.f64 (+.f64 x -1) -1)): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= fma-udef_binary64 (fma.f64 (neg.f64 x) (/.f64 (+.f64 x -1) (+.f64 x 1)) (neg.f64 (*.f64 (fma.f64 -1 x -1) 1)))) (/.f64 (+.f64 x -1) -1)): 3 points increase in error, 2 points decrease in error
      (/.f64 (fma.f64 (neg.f64 x) (/.f64 (+.f64 x -1) (+.f64 x 1)) (neg.f64 (*.f64 (fma.f64 -1 x -1) 1))) (/.f64 (+.f64 x -1) (Rewrite<= metadata-eval (-.f64 0 1)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (fma.f64 (neg.f64 x) (/.f64 (+.f64 x -1) (+.f64 x 1)) (neg.f64 (*.f64 (fma.f64 -1 x -1) 1))) (/.f64 (+.f64 x -1) (-.f64 (Rewrite<= div0_binary64 (/.f64 0 (fma.f64 -1 x -1))) 1))): 0 points increase in error, 0 points decrease in error
      (/.f64 (fma.f64 (neg.f64 x) (/.f64 (+.f64 x -1) (+.f64 x 1)) (neg.f64 (*.f64 (fma.f64 -1 x -1) 1))) (/.f64 (+.f64 x -1) (-.f64 (/.f64 0 (fma.f64 -1 x -1)) (Rewrite<= *-inverses_binary64 (/.f64 (fma.f64 -1 x -1) (fma.f64 -1 x -1)))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (fma.f64 (neg.f64 x) (/.f64 (+.f64 x -1) (+.f64 x 1)) (neg.f64 (*.f64 (fma.f64 -1 x -1) 1))) (/.f64 (+.f64 x -1) (Rewrite<= div-sub_binary64 (/.f64 (-.f64 0 (fma.f64 -1 x -1)) (fma.f64 -1 x -1))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (fma.f64 (neg.f64 x) (/.f64 (+.f64 x -1) (+.f64 x 1)) (neg.f64 (*.f64 (fma.f64 -1 x -1) 1))) (/.f64 (+.f64 x -1) (/.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 (fma.f64 -1 x -1))) (fma.f64 -1 x -1)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (fma.f64 (neg.f64 x) (/.f64 (+.f64 x -1) (+.f64 x 1)) (neg.f64 (*.f64 (fma.f64 -1 x -1) 1))) (/.f64 (+.f64 x -1) (/.f64 (neg.f64 (Rewrite=> fma-udef_binary64 (+.f64 (*.f64 -1 x) -1))) (fma.f64 -1 x -1)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (fma.f64 (neg.f64 x) (/.f64 (+.f64 x -1) (+.f64 x 1)) (neg.f64 (*.f64 (fma.f64 -1 x -1) 1))) (/.f64 (+.f64 x -1) (/.f64 (neg.f64 (+.f64 (Rewrite<= neg-mul-1_binary64 (neg.f64 x)) -1)) (fma.f64 -1 x -1)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (fma.f64 (neg.f64 x) (/.f64 (+.f64 x -1) (+.f64 x 1)) (neg.f64 (*.f64 (fma.f64 -1 x -1) 1))) (/.f64 (+.f64 x -1) (/.f64 (neg.f64 (+.f64 (neg.f64 x) (Rewrite<= metadata-eval (neg.f64 1)))) (fma.f64 -1 x -1)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (fma.f64 (neg.f64 x) (/.f64 (+.f64 x -1) (+.f64 x 1)) (neg.f64 (*.f64 (fma.f64 -1 x -1) 1))) (/.f64 (+.f64 x -1) (/.f64 (neg.f64 (Rewrite<= distribute-neg-in_binary64 (neg.f64 (+.f64 x 1)))) (fma.f64 -1 x -1)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (fma.f64 (neg.f64 x) (/.f64 (+.f64 x -1) (+.f64 x 1)) (neg.f64 (*.f64 (fma.f64 -1 x -1) 1))) (/.f64 (+.f64 x -1) (/.f64 (Rewrite=> remove-double-neg_binary64 (+.f64 x 1)) (fma.f64 -1 x -1)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (fma.f64 (neg.f64 x) (/.f64 (+.f64 x -1) (+.f64 x 1)) (neg.f64 (*.f64 (fma.f64 -1 x -1) 1))) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 (+.f64 x -1) (fma.f64 -1 x -1)) (+.f64 x 1)))): 1 points increase in error, 0 points decrease in error
      (/.f64 (fma.f64 (neg.f64 x) (/.f64 (+.f64 x -1) (+.f64 x 1)) (neg.f64 (*.f64 (fma.f64 -1 x -1) 1))) (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 (fma.f64 -1 x -1) (+.f64 x -1))) (+.f64 x 1))): 0 points increase in error, 0 points decrease in error
      (/.f64 (fma.f64 (neg.f64 x) (/.f64 (+.f64 x -1) (+.f64 x 1)) (neg.f64 (*.f64 (fma.f64 -1 x -1) 1))) (Rewrite<= associate-*r/_binary64 (*.f64 (fma.f64 -1 x -1) (/.f64 (+.f64 x -1) (+.f64 x 1))))): 0 points increase in error, 2 points decrease in error
    4. Taylor expanded in x around inf 0.2

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

      \[\leadsto \frac{\color{blue}{\left(3 + \frac{2}{x \cdot x}\right) - \left(\frac{2}{x} + \frac{2}{{x}^{3}}\right)}}{\frac{x + -1}{-1}} \]
      Proof
      (-.f64 (+.f64 3 (/.f64 2 (*.f64 x x))) (+.f64 (/.f64 2 x) (/.f64 2 (pow.f64 x 3)))): 0 points increase in error, 0 points decrease in error
      (-.f64 (+.f64 3 (/.f64 (Rewrite<= metadata-eval (*.f64 2 1)) (*.f64 x x))) (+.f64 (/.f64 2 x) (/.f64 2 (pow.f64 x 3)))): 0 points increase in error, 0 points decrease in error
      (-.f64 (+.f64 3 (/.f64 (*.f64 2 1) (Rewrite<= unpow2_binary64 (pow.f64 x 2)))) (+.f64 (/.f64 2 x) (/.f64 2 (pow.f64 x 3)))): 0 points increase in error, 0 points decrease in error
      (-.f64 (+.f64 3 (Rewrite<= associate-*r/_binary64 (*.f64 2 (/.f64 1 (pow.f64 x 2))))) (+.f64 (/.f64 2 x) (/.f64 2 (pow.f64 x 3)))): 0 points increase in error, 0 points decrease in error
      (-.f64 (+.f64 3 (*.f64 2 (/.f64 1 (pow.f64 x 2)))) (+.f64 (/.f64 (Rewrite<= metadata-eval (*.f64 2 1)) x) (/.f64 2 (pow.f64 x 3)))): 0 points increase in error, 0 points decrease in error
      (-.f64 (+.f64 3 (*.f64 2 (/.f64 1 (pow.f64 x 2)))) (+.f64 (Rewrite<= associate-*r/_binary64 (*.f64 2 (/.f64 1 x))) (/.f64 2 (pow.f64 x 3)))): 0 points increase in error, 0 points decrease in error
      (-.f64 (+.f64 3 (*.f64 2 (/.f64 1 (pow.f64 x 2)))) (+.f64 (*.f64 2 (/.f64 1 x)) (/.f64 (Rewrite<= metadata-eval (*.f64 2 1)) (pow.f64 x 3)))): 0 points increase in error, 0 points decrease in error
      (-.f64 (+.f64 3 (*.f64 2 (/.f64 1 (pow.f64 x 2)))) (+.f64 (*.f64 2 (/.f64 1 x)) (Rewrite<= associate-*r/_binary64 (*.f64 2 (/.f64 1 (pow.f64 x 3)))))): 0 points increase in error, 0 points decrease in error

    if 1.00000000000000004e-10 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1)))

    1. Initial program 0.2

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

      \[\leadsto \color{blue}{\frac{\frac{x + -1}{x + 1} - \frac{x + 1}{x} \cdot 1}{\frac{x + 1}{x} \cdot \frac{x + -1}{x + 1}}} \]
    3. Taylor expanded in x around 0 0.3

      \[\leadsto \frac{\frac{x + -1}{x + 1} - \frac{x + 1}{x} \cdot 1}{\color{blue}{1 - \frac{1}{x}}} \]
    4. Applied egg-rr0.3

      \[\leadsto \color{blue}{0 + \frac{\frac{x + -1}{x + 1} - \frac{x + 1}{x}}{1 + \frac{-1}{x}}} \]
    5. Simplified0.3

      \[\leadsto \color{blue}{\frac{\frac{x + -1}{1 + x} - \frac{1 + x}{x}}{1 + \frac{-1}{x}}} \]
      Proof
      (/.f64 (-.f64 (/.f64 (+.f64 x -1) (+.f64 1 x)) (/.f64 (+.f64 1 x) x)) (+.f64 1 (/.f64 -1 x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (/.f64 (+.f64 x -1) (Rewrite<= +-commutative_binary64 (+.f64 x 1))) (/.f64 (+.f64 1 x) x)) (+.f64 1 (/.f64 -1 x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (/.f64 (+.f64 x -1) (+.f64 x 1)) (/.f64 (Rewrite<= +-commutative_binary64 (+.f64 x 1)) x)) (+.f64 1 (/.f64 -1 x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (/.f64 (+.f64 x -1) (+.f64 x 1)) (Rewrite<= *-rgt-identity_binary64 (*.f64 (/.f64 (+.f64 x 1) x) 1))) (+.f64 1 (/.f64 -1 x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (Rewrite<= --rgt-identity_binary64 (-.f64 (/.f64 (+.f64 x -1) (+.f64 x 1)) 0)) (*.f64 (/.f64 (+.f64 x 1) x) 1)) (+.f64 1 (/.f64 -1 x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (-.f64 (/.f64 (+.f64 x -1) (+.f64 x 1)) 0) (Rewrite=> *-rgt-identity_binary64 (/.f64 (+.f64 x 1) x))) (+.f64 1 (/.f64 -1 x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (Rewrite=> --rgt-identity_binary64 (/.f64 (+.f64 x -1) (+.f64 x 1))) (/.f64 (+.f64 x 1) x)) (+.f64 1 (/.f64 -1 x))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= +-lft-identity_binary64 (+.f64 0 (/.f64 (-.f64 (/.f64 (+.f64 x -1) (+.f64 x 1)) (/.f64 (+.f64 x 1) x)) (+.f64 1 (/.f64 -1 x))))): 0 points increase in error, 0 points decrease in error
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

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

Alternatives

Alternative 1
Error0.3
Cost1732
\[\begin{array}{l} t_0 := \frac{x}{x + 1} - \frac{x + 1}{x + -1}\\ \mathbf{if}\;t_0 \leq 10^{-10}:\\ \;\;\;\;\frac{-3 + \frac{2 + \frac{-2}{x}}{x}}{x + -1}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error0.1
Cost1480
\[\begin{array}{l} \mathbf{if}\;x \leq -320000:\\ \;\;\;\;\frac{\frac{x + 0.3333333333333333}{x} \cdot -3}{x}\\ \mathbf{elif}\;x \leq 11000:\\ \;\;\;\;\frac{\frac{x + -1}{x + 1} - \frac{x + 1}{x}}{1 + \frac{-1}{x}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{-3}{x} + \frac{\frac{-1}{x}}{x}\right) + \frac{\frac{-3}{x}}{x \cdot x}\\ \end{array} \]
Alternative 3
Error0.1
Cost1352
\[\begin{array}{l} \mathbf{if}\;x \leq -420000:\\ \;\;\;\;\frac{\frac{x + 0.3333333333333333}{x} \cdot -3}{x}\\ \mathbf{elif}\;x \leq 11000:\\ \;\;\;\;\frac{x}{x + 1} - \frac{x + 1}{x + -1}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{-3}{x} + \frac{\frac{-1}{x}}{x}\right) + \frac{\frac{-3}{x}}{x \cdot x}\\ \end{array} \]
Alternative 4
Error0.1
Cost1096
\[\begin{array}{l} \mathbf{if}\;x \leq -420000:\\ \;\;\;\;\frac{\frac{x + 0.3333333333333333}{x} \cdot -3}{x}\\ \mathbf{elif}\;x \leq 390000:\\ \;\;\;\;\frac{x}{x + 1} - \frac{x + 1}{x + -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{-3}{x} + \frac{\frac{-1}{x}}{x}\\ \end{array} \]
Alternative 5
Error0.9
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\frac{-3}{x}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;x \cdot \left(x + \left(3 + \frac{1}{x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-3}{x}\\ \end{array} \]
Alternative 6
Error0.6
Cost840
\[\begin{array}{l} t_0 := \frac{-3}{x} + \frac{\frac{-1}{x}}{x}\\ \mathbf{if}\;x \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;x \cdot \left(x + \left(3 + \frac{1}{x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error0.6
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\frac{\frac{x + 0.3333333333333333}{x} \cdot -3}{x}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;x \cdot \left(x + \left(3 + \frac{1}{x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-3}{x} + \frac{\frac{-1}{x}}{x}\\ \end{array} \]
Alternative 8
Error0.6
Cost840
\[\begin{array}{l} t_0 := \frac{\frac{2}{x} + -3}{x + -1}\\ \mathbf{if}\;x \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.85:\\ \;\;\;\;x \cdot \left(x + \left(3 + \frac{1}{x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 9
Error0.9
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\frac{-3}{x}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;1 + x \cdot 3\\ \mathbf{else}:\\ \;\;\;\;\frac{-3}{x}\\ \end{array} \]
Alternative 10
Error1.2
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\frac{-3}{x}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;x + 1\\ \mathbf{else}:\\ \;\;\;\;\frac{-3}{x}\\ \end{array} \]
Alternative 11
Error31.8
Cost64
\[1 \]

Error

Reproduce

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