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

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{-26}:\\
\;\;\;\;\frac{2}{{x}^{5}} + \frac{2}{{x}^{3}}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original9.4
Target0.3
Herbie0.4
\[\frac{2}{x \cdot \left(x \cdot x - 1\right)} \]

Derivation

  1. Split input into 3 regimes
  2. if (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < -5

    1. Initial program 0.0

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \]
    2. Simplified0.0

      \[\leadsto \color{blue}{\frac{1}{1 + x} + \left(\frac{1}{x + -1} + \frac{-2}{x}\right)} \]
      Proof
      (+.f64 (/.f64 1 (+.f64 1 x)) (+.f64 (/.f64 1 (+.f64 x -1)) (/.f64 -2 x))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 1 (Rewrite<= +-commutative_binary64 (+.f64 x 1))) (+.f64 (/.f64 1 (+.f64 x -1)) (/.f64 -2 x))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 1 (+.f64 x 1)) (+.f64 (/.f64 1 (+.f64 x (Rewrite<= metadata-eval (neg.f64 1)))) (/.f64 -2 x))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 1 (+.f64 x 1)) (+.f64 (/.f64 1 (Rewrite<= sub-neg_binary64 (-.f64 x 1))) (/.f64 -2 x))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 1 (+.f64 x 1)) (+.f64 (/.f64 1 (-.f64 x 1)) (/.f64 (Rewrite<= metadata-eval (neg.f64 2)) x))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 1 (+.f64 x 1)) (+.f64 (/.f64 1 (-.f64 x 1)) (Rewrite<= distribute-neg-frac_binary64 (neg.f64 (/.f64 2 x))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 1 (+.f64 x 1)) (Rewrite<= +-commutative_binary64 (+.f64 (neg.f64 (/.f64 2 x)) (/.f64 1 (-.f64 x 1))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 (/.f64 1 (+.f64 x 1)) (neg.f64 (/.f64 2 x))) (/.f64 1 (-.f64 x 1)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite<= sub-neg_binary64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x))) (/.f64 1 (-.f64 x 1))): 0 points increase in error, 0 points decrease in error
    3. Applied egg-rr64.0

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{x + -1} + \left(\frac{-2}{x} + \frac{1}{1 + x}\right)\right)} - 1} \]
    4. Simplified0.0

      \[\leadsto \color{blue}{\frac{-2}{x} + \left(\frac{1}{x + -1} + \frac{1}{x + 1}\right)} \]
      Proof
      (+.f64 (/.f64 -2 x) (+.f64 (/.f64 1 (+.f64 x -1)) (/.f64 1 (+.f64 x 1)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 -2 x) (+.f64 (/.f64 1 (+.f64 x -1)) (/.f64 1 (Rewrite<= +-commutative_binary64 (+.f64 1 x))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 (/.f64 -2 x) (/.f64 1 (+.f64 x -1))) (/.f64 1 (+.f64 1 x)))): 3 points increase in error, 3 points decrease in error
      (+.f64 (Rewrite<= +-commutative_binary64 (+.f64 (/.f64 1 (+.f64 x -1)) (/.f64 -2 x))) (/.f64 1 (+.f64 1 x))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-+r+_binary64 (+.f64 (/.f64 1 (+.f64 x -1)) (+.f64 (/.f64 -2 x) (/.f64 1 (+.f64 1 x))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= expm1-log1p_binary64 (expm1.f64 (log1p.f64 (+.f64 (/.f64 1 (+.f64 x -1)) (+.f64 (/.f64 -2 x) (/.f64 1 (+.f64 1 x))))))): 131 points increase in error, 0 points decrease in error
      (Rewrite<= expm1-def_binary64 (-.f64 (exp.f64 (log1p.f64 (+.f64 (/.f64 1 (+.f64 x -1)) (+.f64 (/.f64 -2 x) (/.f64 1 (+.f64 1 x)))))) 1)): 14 points increase in error, 2 points decrease in error
    5. Applied egg-rr0.0

      \[\leadsto \frac{-2}{x} + \color{blue}{\frac{\mathsf{fma}\left(x, -1, -1\right) + \left(1 - x\right) \cdot 1}{\left(1 - x\right) \cdot \left(1 + x\right)}} \]
    6. Simplified0.0

      \[\leadsto \frac{-2}{x} + \color{blue}{\frac{\left(-x\right) - x}{1 - x \cdot x}} \]
      Proof
      (/.f64 (-.f64 (neg.f64 x) x) (-.f64 1 (*.f64 x x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (Rewrite<= remove-double-neg_binary64 (neg.f64 (neg.f64 (neg.f64 x)))) x) (-.f64 1 (*.f64 x x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (neg.f64 (Rewrite=> remove-double-neg_binary64 x)) x) (-.f64 1 (*.f64 x x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (neg.f64 (Rewrite<= +-lft-identity_binary64 (+.f64 0 x))) x) (-.f64 1 (*.f64 x x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (neg.f64 (+.f64 (Rewrite<= metadata-eval (+.f64 1 -1)) x)) x) (-.f64 1 (*.f64 x x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (neg.f64 (Rewrite<= associate-+r+_binary64 (+.f64 1 (+.f64 -1 x)))) x) (-.f64 1 (*.f64 x x))): 126 points increase in error, 5 points decrease in error
      (/.f64 (-.f64 (neg.f64 (+.f64 1 (Rewrite<= +-commutative_binary64 (+.f64 x -1)))) x) (-.f64 1 (*.f64 x x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (neg.f64 (Rewrite=> associate-+r+_binary64 (+.f64 (+.f64 1 x) -1))) x) (-.f64 1 (*.f64 x x))): 5 points increase in error, 1 points decrease in error
      (/.f64 (-.f64 (Rewrite=> distribute-neg-in_binary64 (+.f64 (neg.f64 (+.f64 1 x)) (neg.f64 -1))) x) (-.f64 1 (*.f64 x x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (+.f64 (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (+.f64 1 x))) (neg.f64 -1)) x) (-.f64 1 (*.f64 x x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 (+.f64 1 x) -1)) (neg.f64 -1)) x) (-.f64 1 (*.f64 x x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (+.f64 (*.f64 (Rewrite=> +-commutative_binary64 (+.f64 x 1)) -1) (neg.f64 -1)) x) (-.f64 1 (*.f64 x x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (+.f64 (Rewrite<= distribute-lft1-in_binary64 (+.f64 (*.f64 x -1) -1)) (neg.f64 -1)) x) (-.f64 1 (*.f64 x x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (+.f64 (Rewrite<= fma-udef_binary64 (fma.f64 x -1 -1)) (neg.f64 -1)) x) (-.f64 1 (*.f64 x x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (+.f64 (fma.f64 x -1 -1) (Rewrite=> metadata-eval 1)) x) (-.f64 1 (*.f64 x x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= associate-+r-_binary64 (+.f64 (fma.f64 x -1 -1) (-.f64 1 x))) (-.f64 1 (*.f64 x x))): 126 points increase in error, 4 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (Rewrite<= *-rgt-identity_binary64 (*.f64 (-.f64 1 x) 1))) (-.f64 1 (*.f64 x x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (-.f64 1 (*.f64 x (Rewrite<= +-lft-identity_binary64 (+.f64 0 x))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (-.f64 1 (*.f64 x (+.f64 (Rewrite<= metadata-eval (+.f64 1 -1)) x)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (-.f64 1 (*.f64 x (Rewrite<= associate-+r+_binary64 (+.f64 1 (+.f64 -1 x)))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (-.f64 1 (*.f64 x (+.f64 1 (Rewrite<= +-commutative_binary64 (+.f64 x -1)))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (-.f64 1 (Rewrite=> distribute-lft-in_binary64 (+.f64 (*.f64 x 1) (*.f64 x (+.f64 x -1)))))): 0 points increase in error, 1 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (-.f64 1 (+.f64 (Rewrite=> *-rgt-identity_binary64 x) (*.f64 x (+.f64 x -1))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (-.f64 1 (+.f64 x (*.f64 x (Rewrite=> +-commutative_binary64 (+.f64 -1 x)))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (-.f64 1 (+.f64 x (Rewrite<= distribute-rgt-out_binary64 (+.f64 (*.f64 -1 x) (*.f64 x x)))))): 1 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (-.f64 1 (+.f64 x (+.f64 (Rewrite<= neg-mul-1_binary64 (neg.f64 x)) (*.f64 x x))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (-.f64 1 (+.f64 x (+.f64 (Rewrite=> neg-sub0_binary64 (-.f64 0 x)) (*.f64 x x))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (-.f64 1 (+.f64 x (Rewrite=> associate-+l-_binary64 (-.f64 0 (-.f64 x (*.f64 x x))))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (-.f64 1 (+.f64 x (-.f64 0 (Rewrite<= unsub-neg_binary64 (+.f64 x (neg.f64 (*.f64 x x)))))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (-.f64 1 (+.f64 x (-.f64 0 (+.f64 (Rewrite<= *-lft-identity_binary64 (*.f64 1 x)) (neg.f64 (*.f64 x x))))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (-.f64 1 (+.f64 x (-.f64 0 (+.f64 (*.f64 1 x) (Rewrite<= distribute-lft-neg-out_binary64 (*.f64 (neg.f64 x) x))))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (-.f64 1 (+.f64 x (-.f64 0 (Rewrite<= distribute-rgt-in_binary64 (*.f64 x (+.f64 1 (neg.f64 x)))))))): 0 points increase in error, 1 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (-.f64 1 (+.f64 x (-.f64 0 (*.f64 x (Rewrite<= sub-neg_binary64 (-.f64 1 x))))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (-.f64 1 (+.f64 x (Rewrite=> sub0-neg_binary64 (neg.f64 (*.f64 x (-.f64 1 x))))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (-.f64 1 (Rewrite<= sub-neg_binary64 (-.f64 x (*.f64 x (-.f64 1 x)))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 1 x) (*.f64 x (-.f64 1 x))))): 1 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (+.f64 (Rewrite<= *-lft-identity_binary64 (*.f64 1 (-.f64 1 x))) (*.f64 x (-.f64 1 x)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (fma.f64 x -1 -1) (*.f64 (-.f64 1 x) 1)) (Rewrite<= distribute-rgt-in_binary64 (*.f64 (-.f64 1 x) (+.f64 1 x)))): 3 points increase in error, 2 points decrease in error

    if -5 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < 2.0000000000000001e-26

    1. Initial program 18.7

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \]
    2. Simplified18.7

      \[\leadsto \color{blue}{\frac{1}{1 + x} + \left(\frac{1}{x + -1} + \frac{-2}{x}\right)} \]
      Proof
      (+.f64 (/.f64 1 (+.f64 1 x)) (+.f64 (/.f64 1 (+.f64 x -1)) (/.f64 -2 x))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 1 (Rewrite<= +-commutative_binary64 (+.f64 x 1))) (+.f64 (/.f64 1 (+.f64 x -1)) (/.f64 -2 x))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 1 (+.f64 x 1)) (+.f64 (/.f64 1 (+.f64 x (Rewrite<= metadata-eval (neg.f64 1)))) (/.f64 -2 x))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 1 (+.f64 x 1)) (+.f64 (/.f64 1 (Rewrite<= sub-neg_binary64 (-.f64 x 1))) (/.f64 -2 x))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 1 (+.f64 x 1)) (+.f64 (/.f64 1 (-.f64 x 1)) (/.f64 (Rewrite<= metadata-eval (neg.f64 2)) x))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 1 (+.f64 x 1)) (+.f64 (/.f64 1 (-.f64 x 1)) (Rewrite<= distribute-neg-frac_binary64 (neg.f64 (/.f64 2 x))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 1 (+.f64 x 1)) (Rewrite<= +-commutative_binary64 (+.f64 (neg.f64 (/.f64 2 x)) (/.f64 1 (-.f64 x 1))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 (/.f64 1 (+.f64 x 1)) (neg.f64 (/.f64 2 x))) (/.f64 1 (-.f64 x 1)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite<= sub-neg_binary64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x))) (/.f64 1 (-.f64 x 1))): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in x around inf 0.6

      \[\leadsto \color{blue}{2 \cdot \frac{1}{{x}^{5}} + 2 \cdot \frac{1}{{x}^{3}}} \]
    4. Simplified0.6

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

    if 2.0000000000000001e-26 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1)))

    1. Initial program 0.9

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \]
    2. Simplified0.9

      \[\leadsto \color{blue}{\frac{1}{1 + x} + \left(\frac{1}{x + -1} + \frac{-2}{x}\right)} \]
      Proof
      (+.f64 (/.f64 1 (+.f64 1 x)) (+.f64 (/.f64 1 (+.f64 x -1)) (/.f64 -2 x))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 1 (Rewrite<= +-commutative_binary64 (+.f64 x 1))) (+.f64 (/.f64 1 (+.f64 x -1)) (/.f64 -2 x))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 1 (+.f64 x 1)) (+.f64 (/.f64 1 (+.f64 x (Rewrite<= metadata-eval (neg.f64 1)))) (/.f64 -2 x))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 1 (+.f64 x 1)) (+.f64 (/.f64 1 (Rewrite<= sub-neg_binary64 (-.f64 x 1))) (/.f64 -2 x))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 1 (+.f64 x 1)) (+.f64 (/.f64 1 (-.f64 x 1)) (/.f64 (Rewrite<= metadata-eval (neg.f64 2)) x))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 1 (+.f64 x 1)) (+.f64 (/.f64 1 (-.f64 x 1)) (Rewrite<= distribute-neg-frac_binary64 (neg.f64 (/.f64 2 x))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 1 (+.f64 x 1)) (Rewrite<= +-commutative_binary64 (+.f64 (neg.f64 (/.f64 2 x)) (/.f64 1 (-.f64 x 1))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 (/.f64 1 (+.f64 x 1)) (neg.f64 (/.f64 2 x))) (/.f64 1 (-.f64 x 1)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite<= sub-neg_binary64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x))) (/.f64 1 (-.f64 x 1))): 0 points increase in error, 0 points decrease in error
    3. Applied egg-rr0.9

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

      \[\leadsto \color{blue}{\frac{1 - x}{1 - x \cdot x}} + \left(\frac{1}{x + -1} + \frac{-2}{x}\right) \]
      Proof
      (/.f64 (-.f64 1 x) (-.f64 1 (*.f64 x x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= *-lft-identity_binary64 (*.f64 1 (-.f64 1 x))) (-.f64 1 (*.f64 x x))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 1 (-.f64 1 (*.f64 x x))) (-.f64 1 x))): 7 points increase in error, 8 points decrease in error
    5. Applied egg-rr0.2

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

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

Alternatives

Alternative 1
Error0.3
Cost8900
\[\begin{array}{l} t_0 := x \cdot \left(x + -1\right)\\ t_1 := \left(\frac{-2}{x} + \frac{1}{1 + x}\right) + \frac{1}{x + -1}\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{-19}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-2, \left(1 - x\right) \cdot \left(-1 - x\right), x \cdot \left(x + x\right)\right)}{\left(1 - x\right) \cdot \left(x \cdot \left(-1 - x\right)\right)}\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{-26}:\\ \;\;\;\;\frac{2}{{x}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0 + \left(1 + x\right) \cdot \left(x + -2 \cdot \left(x + -1\right)\right)}{t_0 \cdot \left(1 + x\right)}\\ \end{array} \]
Alternative 2
Error0.3
Cost8712
\[\begin{array}{l} t_0 := x - x \cdot x\\ t_1 := \left(\frac{-2}{x} + \frac{1}{1 + x}\right) + \frac{1}{x + -1}\\ t_2 := x \cdot \left(x + -1\right)\\ \mathbf{if}\;t_1 \leq -4 \cdot 10^{-24}:\\ \;\;\;\;\frac{\frac{t_0 + \left(1 + x\right) \cdot \left(x + -2\right)}{1 + x}}{t_0}\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{-26}:\\ \;\;\;\;\frac{2}{{x}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_2 + \left(1 + x\right) \cdot \left(x + -2 \cdot \left(x + -1\right)\right)}{t_2 \cdot \left(1 + x\right)}\\ \end{array} \]
Alternative 3
Error10.0
Cost1096
\[\begin{array}{l} \mathbf{if}\;x \leq -0.62:\\ \;\;\;\;\frac{1}{1 + x} + \frac{-1}{x}\\ \mathbf{elif}\;x \leq 1.55:\\ \;\;\;\;\left(1 - x\right) + \left(\frac{-2}{x} + \frac{1}{x + -1}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{x} - \frac{2}{x}\\ \end{array} \]
Alternative 4
Error10.0
Cost1096
\[\begin{array}{l} \mathbf{if}\;x \leq -0.62:\\ \;\;\;\;\frac{1}{1 + x} + \frac{-1}{x}\\ \mathbf{elif}\;x \leq 1.55:\\ \;\;\;\;\frac{-2}{x} + \left(\left(1 - x\right) + \frac{1}{x + -1}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{x} - \frac{2}{x}\\ \end{array} \]
Alternative 5
Error9.9
Cost1096
\[\begin{array}{l} \mathbf{if}\;x \leq -0.65:\\ \;\;\;\;\frac{1}{1 + x} + \frac{-1}{x}\\ \mathbf{elif}\;x \leq 0.65:\\ \;\;\;\;x \cdot -2 - \frac{2}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2}{x} + \left(\frac{1}{x} + \frac{1}{x + -1}\right)\\ \end{array} \]
Alternative 6
Error9.9
Cost1096
\[\begin{array}{l} \mathbf{if}\;x \leq -0.65:\\ \;\;\;\;\frac{1}{1 + x} + \frac{-1}{x}\\ \mathbf{elif}\;x \leq 0.65:\\ \;\;\;\;x \cdot -2 - \frac{2}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x} + \left(\frac{-2}{x} + \frac{1}{x + -1}\right)\\ \end{array} \]
Alternative 7
Error9.4
Cost1096
\[\begin{array}{l} \mathbf{if}\;x \leq -90000000:\\ \;\;\;\;\frac{1}{1 + x} + \frac{-1}{x}\\ \mathbf{elif}\;x \leq 400000000:\\ \;\;\;\;\frac{-2}{x} - \frac{x + x}{1 - x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2}{x} + \frac{-2 - \frac{2}{x}}{-1 - x}\\ \end{array} \]
Alternative 8
Error9.4
Cost960
\[\left(\frac{-2}{x} + \frac{1}{1 + x}\right) + \frac{1}{x + -1} \]
Alternative 9
Error9.4
Cost960
\[\frac{-2}{x} + \frac{\frac{x + x}{1 - x}}{-1 - x} \]
Alternative 10
Error10.2
Cost712
\[\begin{array}{l} t_0 := \frac{2}{x} - \frac{2}{x}\\ \mathbf{if}\;x \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\frac{-2}{x} - x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 11
Error10.0
Cost712
\[\begin{array}{l} t_0 := \frac{2}{x} - \frac{2}{x}\\ \mathbf{if}\;x \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;x \cdot -2 - \frac{2}{x}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 12
Error10.0
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -0.65:\\ \;\;\;\;\frac{1}{1 + x} + \frac{-1}{x}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;x \cdot -2 - \frac{2}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{x} - \frac{2}{x}\\ \end{array} \]
Alternative 13
Error30.7
Cost192
\[\frac{-2}{x} \]
Alternative 14
Error61.9
Cost64
\[1 \]

Error

Reproduce

herbie shell --seed 2022332 
(FPCore (x)
  :name "3frac (problem 3.3.3)"
  :precision binary64

  :herbie-target
  (/ 2.0 (* x (- (* x x) 1.0)))

  (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))