Average Error: 29.8 → 0.3
Time: 4.6s
Precision: binary64
Cost: 2116
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1} \]
\[\begin{array}{l} \mathbf{if}\;\frac{x}{x + 1} - \frac{x + 1}{x - 1} \leq 4 \cdot 10^{-11}:\\ \;\;\;\;\frac{\frac{-1}{x}}{x} + \frac{-3}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x + 1\right) + \frac{1 - x}{\frac{x + 1}{x}}}{\frac{x - 1}{-1}}\\ \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))) 4e-11)
   (+ (/ (/ -1.0 x) x) (/ -3.0 x))
   (/ (+ (+ x 1.0) (/ (- 1.0 x) (/ (+ x 1.0) x))) (/ (- x 1.0) -1.0))))
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))) <= 4e-11) {
		tmp = ((-1.0 / x) / x) + (-3.0 / x);
	} else {
		tmp = ((x + 1.0) + ((1.0 - x) / ((x + 1.0) / x))) / ((x - 1.0) / -1.0);
	}
	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))) <= 4d-11) then
        tmp = (((-1.0d0) / x) / x) + ((-3.0d0) / x)
    else
        tmp = ((x + 1.0d0) + ((1.0d0 - x) / ((x + 1.0d0) / x))) / ((x - 1.0d0) / (-1.0d0))
    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))) <= 4e-11) {
		tmp = ((-1.0 / x) / x) + (-3.0 / x);
	} else {
		tmp = ((x + 1.0) + ((1.0 - x) / ((x + 1.0) / x))) / ((x - 1.0) / -1.0);
	}
	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))) <= 4e-11:
		tmp = ((-1.0 / x) / x) + (-3.0 / x)
	else:
		tmp = ((x + 1.0) + ((1.0 - x) / ((x + 1.0) / x))) / ((x - 1.0) / -1.0)
	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))) <= 4e-11)
		tmp = Float64(Float64(Float64(-1.0 / x) / x) + Float64(-3.0 / x));
	else
		tmp = Float64(Float64(Float64(x + 1.0) + Float64(Float64(1.0 - x) / Float64(Float64(x + 1.0) / x))) / Float64(Float64(x - 1.0) / -1.0));
	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))) <= 4e-11)
		tmp = ((-1.0 / x) / x) + (-3.0 / x);
	else
		tmp = ((x + 1.0) + ((1.0 - x) / ((x + 1.0) / x))) / ((x - 1.0) / -1.0);
	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], 4e-11], N[(N[(N[(-1.0 / x), $MachinePrecision] / x), $MachinePrecision] + N[(-3.0 / x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + 1.0), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x - 1.0), $MachinePrecision] / -1.0), $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 4 \cdot 10^{-11}:\\
\;\;\;\;\frac{\frac{-1}{x}}{x} + \frac{-3}{x}\\

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


\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))) < 3.99999999999999976e-11

    1. Initial program 59.4

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

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

      \[\leadsto \color{blue}{\frac{\frac{-1}{x}}{x} + \frac{-3}{x}} \]
      Proof
      (+.f64 (/.f64 (/.f64 -1 x) x) (/.f64 -3 x)): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 (/.f64 (Rewrite<= metadata-eval (neg.f64 1)) x) x) (/.f64 -3 x)): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 (Rewrite<= distribute-neg-frac_binary64 (neg.f64 (/.f64 1 x))) x) (/.f64 -3 x)): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 (neg.f64 (/.f64 (Rewrite<= metadata-eval (neg.f64 -1)) x)) x) (/.f64 -3 x)): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 (neg.f64 (Rewrite<= distribute-neg-frac_binary64 (neg.f64 (/.f64 -1 x)))) x) (/.f64 -3 x)): 0 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite<= distribute-neg-frac_binary64 (neg.f64 (/.f64 (neg.f64 (/.f64 -1 x)) x))) (/.f64 -3 x)): 0 points increase in error, 0 points decrease in error
      (+.f64 (neg.f64 (/.f64 (Rewrite=> neg-mul-1_binary64 (*.f64 -1 (/.f64 -1 x))) x)) (/.f64 -3 x)): 0 points increase in error, 0 points decrease in error
      (+.f64 (neg.f64 (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 -1 x) (/.f64 -1 x)))) (/.f64 -3 x)): 3 points increase in error, 7 points decrease in error
      (+.f64 (neg.f64 (Rewrite<= unpow2_binary64 (pow.f64 (/.f64 -1 x) 2))) (/.f64 -3 x)): 0 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (pow.f64 (/.f64 -1 x) 2))) (/.f64 -3 x)): 0 points increase in error, 0 points decrease in error
      (+.f64 (*.f64 -1 (pow.f64 (/.f64 -1 x) 2)) (/.f64 (Rewrite<= metadata-eval (neg.f64 3)) x)): 0 points increase in error, 0 points decrease in error
      (+.f64 (*.f64 -1 (pow.f64 (/.f64 -1 x) 2)) (Rewrite<= distribute-neg-frac_binary64 (neg.f64 (/.f64 3 x)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (*.f64 -1 (pow.f64 (/.f64 -1 x) 2)) (neg.f64 (/.f64 (Rewrite<= metadata-eval (*.f64 3 1)) x))): 0 points increase in error, 0 points decrease in error
      (+.f64 (*.f64 -1 (pow.f64 (/.f64 -1 x) 2)) (neg.f64 (Rewrite<= associate-*r/_binary64 (*.f64 3 (/.f64 1 x))))): 38 points increase in error, 0 points decrease in error
      (Rewrite<= fma-udef_binary64 (fma.f64 -1 (pow.f64 (/.f64 -1 x) 2) (neg.f64 (*.f64 3 (/.f64 1 x))))): 0 points increase in error, 0 points decrease in error
      (fma.f64 -1 (Rewrite=> unpow2_binary64 (*.f64 (/.f64 -1 x) (/.f64 -1 x))) (neg.f64 (*.f64 3 (/.f64 1 x)))): 0 points increase in error, 0 points decrease in error
      (fma.f64 -1 (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 -1 (/.f64 -1 x)) x)) (neg.f64 (*.f64 3 (/.f64 1 x)))): 7 points increase in error, 3 points decrease in error
      (fma.f64 -1 (/.f64 (Rewrite<= neg-mul-1_binary64 (neg.f64 (/.f64 -1 x))) x) (neg.f64 (*.f64 3 (/.f64 1 x)))): 0 points increase in error, 0 points decrease in error
      (fma.f64 -1 (/.f64 (Rewrite=> distribute-neg-frac_binary64 (/.f64 (neg.f64 -1) x)) x) (neg.f64 (*.f64 3 (/.f64 1 x)))): 0 points increase in error, 0 points decrease in error
      (fma.f64 -1 (/.f64 (/.f64 (Rewrite=> metadata-eval 1) x) x) (neg.f64 (*.f64 3 (/.f64 1 x)))): 0 points increase in error, 0 points decrease in error
      (fma.f64 -1 (/.f64 (Rewrite<= *-lft-identity_binary64 (*.f64 1 (/.f64 1 x))) x) (neg.f64 (*.f64 3 (/.f64 1 x)))): 0 points increase in error, 0 points decrease in error
      (fma.f64 -1 (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 1 x) (/.f64 1 x))) (neg.f64 (*.f64 3 (/.f64 1 x)))): 3 points increase in error, 7 points decrease in error
      (fma.f64 -1 (Rewrite<= unpow2_binary64 (pow.f64 (/.f64 1 x) 2)) (neg.f64 (*.f64 3 (/.f64 1 x)))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= fma-neg_binary64 (-.f64 (*.f64 -1 (pow.f64 (/.f64 1 x) 2)) (*.f64 3 (/.f64 1 x)))): 0 points increase in error, 0 points decrease in error

    if 3.99999999999999976e-11 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1)))

    1. Initial program 0.3

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1} \]
    2. Applied egg-rr0.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. Simplified0.3

      \[\leadsto \color{blue}{\frac{\left(1 + x\right) + \frac{1 - x}{\frac{1 + x}{x}}}{\frac{x + -1}{-1}}} \]
      Proof
      (/.f64 (+.f64 (+.f64 1 x) (/.f64 (-.f64 1 x) (/.f64 (+.f64 1 x) x))) (/.f64 (+.f64 x -1) -1)): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (Rewrite<= +-commutative_binary64 (+.f64 x 1)) (/.f64 (-.f64 1 x) (/.f64 (+.f64 1 x) x))) (/.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)))) (/.f64 (-.f64 1 x) (/.f64 (+.f64 1 x) x))) (/.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)))) (/.f64 (-.f64 1 x) (/.f64 (+.f64 1 x) x))) (/.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))) (/.f64 (-.f64 1 x) (/.f64 (+.f64 1 x) x))) (/.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))) (/.f64 (-.f64 1 x) (/.f64 (+.f64 1 x) x))) (/.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))) (/.f64 (-.f64 1 x) (/.f64 (+.f64 1 x) x))) (/.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))) (/.f64 (-.f64 1 x) (/.f64 (+.f64 1 x) x))) (/.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)) (/.f64 (Rewrite<= unsub-neg_binary64 (+.f64 1 (neg.f64 x))) (/.f64 (+.f64 1 x) x))) (/.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)) (/.f64 (Rewrite<= +-commutative_binary64 (+.f64 (neg.f64 x) 1)) (/.f64 (+.f64 1 x) x))) (/.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)) (/.f64 (+.f64 (Rewrite=> neg-sub0_binary64 (-.f64 0 x)) 1) (/.f64 (+.f64 1 x) x))) (/.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)) (/.f64 (Rewrite=> associate-+l-_binary64 (-.f64 0 (-.f64 x 1))) (/.f64 (+.f64 1 x) x))) (/.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)) (/.f64 (-.f64 0 (Rewrite=> sub-neg_binary64 (+.f64 x (neg.f64 1)))) (/.f64 (+.f64 1 x) x))) (/.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)) (/.f64 (-.f64 0 (+.f64 x (Rewrite=> metadata-eval -1))) (/.f64 (+.f64 1 x) x))) (/.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)) (/.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 (+.f64 x -1))) (/.f64 (+.f64 1 x) x))) (/.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)) (/.f64 (neg.f64 (+.f64 x -1)) (/.f64 (Rewrite<= +-commutative_binary64 (+.f64 x 1)) x))) (/.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-neg-frac_binary64 (neg.f64 (/.f64 (+.f64 x -1) (/.f64 (+.f64 x 1) x))))) (/.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)) (neg.f64 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 (+.f64 x -1) x) (+.f64 x 1))))) (/.f64 (+.f64 x -1) -1)): 70 points increase in error, 2 points decrease in error
      (/.f64 (+.f64 (neg.f64 (*.f64 (fma.f64 -1 x -1) 1)) (neg.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 x (+.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)) (neg.f64 (Rewrite<= associate-*r/_binary64 (*.f64 x (/.f64 (+.f64 x -1) (+.f64 x 1)))))) (/.f64 (+.f64 x -1) -1)): 3 points increase in error, 70 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, 1 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 (neg.f64 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) (neg.f64 (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<= distribute-frac-neg_binary64 (/.f64 (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)))): 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 (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, 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 4 \cdot 10^{-11}:\\ \;\;\;\;\frac{\frac{-1}{x}}{x} + \frac{-3}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x + 1\right) + \frac{1 - x}{\frac{x + 1}{x}}}{\frac{x - 1}{-1}}\\ \end{array} \]

Alternatives

Alternative 1
Error0.4
Cost1860
\[\begin{array}{l} t_0 := \frac{x}{x + 1}\\ \mathbf{if}\;t_0 - \frac{x + 1}{x - 1} \leq 4 \cdot 10^{-11}:\\ \;\;\;\;\frac{\frac{-1}{x}}{x} + \frac{-3}{x}\\ \mathbf{else}:\\ \;\;\;\;t_0 - \left(x + 1\right) \cdot \frac{1}{x - 1}\\ \end{array} \]
Alternative 2
Error0.4
Cost1732
\[\begin{array}{l} t_0 := \frac{x}{x + 1} - \frac{x + 1}{x + -1}\\ \mathbf{if}\;t_0 \leq 4 \cdot 10^{-11}:\\ \;\;\;\;\frac{\frac{-1}{x}}{x} + \frac{-3}{x}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error0.7
Cost840
\[\begin{array}{l} t_0 := \frac{\frac{-1}{x}}{x} + \frac{-3}{x}\\ \mathbf{if}\;x \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;1 + x \cdot 3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error1.0
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 5
Error1.4
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\frac{-3}{x}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{-3}{x}\\ \end{array} \]
Alternative 6
Error32.0
Cost64
\[1 \]

Error

Reproduce

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