?

Average Error: 22.58% → 0.12%
Time: 5.1s
Precision: binary64
Cost: 448

?

\[\frac{1}{x + 1} - \frac{1}{x} \]
\[\frac{\frac{-1}{x}}{x + 1} \]
(FPCore (x) :precision binary64 (- (/ 1.0 (+ x 1.0)) (/ 1.0 x)))
(FPCore (x) :precision binary64 (/ (/ -1.0 x) (+ x 1.0)))
double code(double x) {
	return (1.0 / (x + 1.0)) - (1.0 / x);
}
double code(double x) {
	return (-1.0 / x) / (x + 1.0);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (1.0d0 / (x + 1.0d0)) - (1.0d0 / x)
end function
real(8) function code(x)
    real(8), intent (in) :: x
    code = ((-1.0d0) / x) / (x + 1.0d0)
end function
public static double code(double x) {
	return (1.0 / (x + 1.0)) - (1.0 / x);
}
public static double code(double x) {
	return (-1.0 / x) / (x + 1.0);
}
def code(x):
	return (1.0 / (x + 1.0)) - (1.0 / x)
def code(x):
	return (-1.0 / x) / (x + 1.0)
function code(x)
	return Float64(Float64(1.0 / Float64(x + 1.0)) - Float64(1.0 / x))
end
function code(x)
	return Float64(Float64(-1.0 / x) / Float64(x + 1.0))
end
function tmp = code(x)
	tmp = (1.0 / (x + 1.0)) - (1.0 / x);
end
function tmp = code(x)
	tmp = (-1.0 / x) / (x + 1.0);
end
code[x_] := N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(1.0 / x), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(-1.0 / x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\frac{1}{x + 1} - \frac{1}{x}
\frac{\frac{-1}{x}}{x + 1}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 22.58

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

    \[\leadsto \color{blue}{\frac{x + \left(-1 - x\right)}{x + x \cdot x}} \]
  3. Applied egg-rr21.51

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

    \[\leadsto \color{blue}{\frac{\frac{-1}{x}}{x + 1}} \]
    Proof

    [Start]21.51

    \[ \frac{1}{x + 1} \cdot \frac{\left(x + -1\right) - x}{x} \]

    associate-*l/ [=>]21.5

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

    *-lft-identity [=>]21.5

    \[ \frac{\color{blue}{\frac{\left(x + -1\right) - x}{x}}}{x + 1} \]

    associate--l+ [=>]21.49

    \[ \frac{\frac{\color{blue}{x + \left(-1 - x\right)}}{x}}{x + 1} \]

    +-commutative [=>]21.49

    \[ \frac{\frac{\color{blue}{\left(-1 - x\right) + x}}{x}}{x + 1} \]

    associate--r- [<=]0.12

    \[ \frac{\frac{\color{blue}{-1 - \left(x - x\right)}}{x}}{x + 1} \]

    sub-neg [=>]0.12

    \[ \frac{\frac{\color{blue}{-1 + \left(-\left(x - x\right)\right)}}{x}}{x + 1} \]

    +-inverses [=>]0.12

    \[ \frac{\frac{-1 + \left(-\color{blue}{0}\right)}{x}}{x + 1} \]

    metadata-eval [=>]0.12

    \[ \frac{\frac{-1 + \color{blue}{0}}{x}}{x + 1} \]

    metadata-eval [=>]0.12

    \[ \frac{\frac{\color{blue}{-1}}{x}}{x + 1} \]
  5. Final simplification0.12

    \[\leadsto \frac{\frac{-1}{x}}{x + 1} \]

Alternatives

Alternative 1
Error1.51%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\ \;\;\;\;\frac{\frac{-1}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(1 - x\right) + \frac{-1}{x}\\ \end{array} \]
Alternative 2
Error2.13%
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 0.75\right):\\ \;\;\;\;\frac{-1}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{-1}{x}\\ \end{array} \]
Alternative 3
Error1.7%
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 0.75\right):\\ \;\;\;\;\frac{\frac{-1}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{-1}{x}\\ \end{array} \]
Alternative 4
Error0.55%
Cost448
\[\frac{-1}{x + x \cdot x} \]
Alternative 5
Error48.44%
Cost192
\[\frac{-1}{x} \]
Alternative 6
Error96.86%
Cost128
\[-x \]

Error

Reproduce?

herbie shell --seed 2023090 
(FPCore (x)
  :name "2frac (problem 3.3.1)"
  :precision binary64
  (- (/ 1.0 (+ x 1.0)) (/ 1.0 x)))