?

Average Accuracy: 77.8% → 99.4%
Time: 3.2s
Precision: binary64
Cost: 448

?

\[\frac{1}{x + 1} - \frac{1}{x} \]
\[\frac{-1}{x + x \cdot x} \]
(FPCore (x) :precision binary64 (- (/ 1.0 (+ x 1.0)) (/ 1.0 x)))
(FPCore (x) :precision binary64 (/ -1.0 (+ x (* x x))))
double code(double x) {
	return (1.0 / (x + 1.0)) - (1.0 / x);
}
double code(double x) {
	return -1.0 / (x + (x * x));
}
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 * x))
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 * x));
}
def code(x):
	return (1.0 / (x + 1.0)) - (1.0 / x)
def code(x):
	return -1.0 / (x + (x * x))
function code(x)
	return Float64(Float64(1.0 / Float64(x + 1.0)) - Float64(1.0 / x))
end
function code(x)
	return Float64(-1.0 / Float64(x + Float64(x * x)))
end
function tmp = code(x)
	tmp = (1.0 / (x + 1.0)) - (1.0 / x);
end
function tmp = code(x)
	tmp = -1.0 / (x + (x * x));
end
code[x_] := N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(1.0 / x), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(-1.0 / N[(x + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{1}{x + 1} - \frac{1}{x}
\frac{-1}{x + x \cdot x}

Error?

Bogosity

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 79.2%

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

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

    [Start]79.2

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

    sub-neg [=>]79.2

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

    +-commutative [=>]79.2

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

    distribute-neg-frac [=>]79.2

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

    metadata-eval [=>]79.2

    \[ \frac{1}{1 + x} + \frac{\color{blue}{-1}}{x} \]
  3. Simplified99.3%

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

    [Start]79.2

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

    *-rgt-identity [<=]79.2

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

    cancel-sign-sub [<=]79.2

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

    distribute-neg-frac [=>]79.2

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

    metadata-eval [=>]79.2

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

    *-rgt-identity [<=]79.2

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

    *-inverses [<=]79.2

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

    associate-*r/ [=>]79.2

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

    associate-*l/ [<=]58.0

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

    associate-/r* [<=]58.0

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

    associate-/l/ [<=]58.0

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

    associate-*l/ [=>]79.2

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

    associate-*r/ [<=]79.2

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

    distribute-lft-out-- [=>]79.2

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

    *-inverses [<=]79.2

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

    div-sub [<=]79.5

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

    associate-*l/ [=>]79.5

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

    associate-*r/ [<=]79.5

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

    *-lft-identity [=>]79.5

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

    associate-/l/ [=>]79.5

    \[ \color{blue}{\frac{x - \left(1 + x\right)}{x \cdot \left(1 + x\right)}} \]
  4. Applied egg-rr99.4%

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

    [Start]99.3

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

    distribute-rgt-in [=>]99.4

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

    *-un-lft-identity [<=]99.4

    \[ \frac{-1}{x \cdot x + \color{blue}{x}} \]
  5. Final simplification99.4%

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

Alternatives

Alternative 1
Accuracy97.9%
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 2
Accuracy98.4%
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 3
Accuracy99.4%
Cost448
\[\frac{-1}{x \cdot \left(x + 1\right)} \]
Alternative 4
Accuracy52.0%
Cost192
\[\frac{-1}{x} \]

Error

Reproduce?

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