Average Error: 0.0 → 0.0
Time: 4.2s
Precision: binary64
Cost: 7424
\[\frac{x + y}{x - y} \]
\[{\left(x \cdot \frac{1}{x + y} + y \cdot \frac{-1}{x + y}\right)}^{-1} \]
(FPCore (x y) :precision binary64 (/ (+ x y) (- x y)))
(FPCore (x y)
 :precision binary64
 (pow (+ (* x (/ 1.0 (+ x y))) (* y (/ -1.0 (+ x y)))) -1.0))
double code(double x, double y) {
	return (x + y) / (x - y);
}
double code(double x, double y) {
	return pow(((x * (1.0 / (x + y))) + (y * (-1.0 / (x + y)))), -1.0);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x + y) / (x - y)
end function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = ((x * (1.0d0 / (x + y))) + (y * ((-1.0d0) / (x + y)))) ** (-1.0d0)
end function
public static double code(double x, double y) {
	return (x + y) / (x - y);
}
public static double code(double x, double y) {
	return Math.pow(((x * (1.0 / (x + y))) + (y * (-1.0 / (x + y)))), -1.0);
}
def code(x, y):
	return (x + y) / (x - y)
def code(x, y):
	return math.pow(((x * (1.0 / (x + y))) + (y * (-1.0 / (x + y)))), -1.0)
function code(x, y)
	return Float64(Float64(x + y) / Float64(x - y))
end
function code(x, y)
	return Float64(Float64(x * Float64(1.0 / Float64(x + y))) + Float64(y * Float64(-1.0 / Float64(x + y)))) ^ -1.0
end
function tmp = code(x, y)
	tmp = (x + y) / (x - y);
end
function tmp = code(x, y)
	tmp = ((x * (1.0 / (x + y))) + (y * (-1.0 / (x + y)))) ^ -1.0;
end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[Power[N[(N[(x * N[(1.0 / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * N[(-1.0 / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]
\frac{x + y}{x - y}
{\left(x \cdot \frac{1}{x + y} + y \cdot \frac{-1}{x + y}\right)}^{-1}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.0
Target0.0
Herbie0.0
\[\frac{1}{\frac{x}{x + y} - \frac{y}{x + y}} \]

Derivation

  1. Initial program 0.0

    \[\frac{x + y}{x - y} \]
  2. Applied egg-rr1.3

    \[\leadsto \color{blue}{\frac{{\left(\sqrt[3]{x + y}\right)}^{2}}{1} \cdot \frac{\sqrt[3]{x + y}}{x - y}} \]
  3. Applied egg-rr32.0

    \[\leadsto \color{blue}{\frac{\frac{x + y}{\sqrt{x - y}}}{\sqrt{x - y}}} \]
  4. Applied egg-rr0.0

    \[\leadsto \color{blue}{{\left(\frac{1}{x + y} \cdot \left(x - y\right)\right)}^{-1}} \]
  5. Applied egg-rr0.0

    \[\leadsto {\color{blue}{\left(\frac{1}{x + y} \cdot x + \frac{1}{x + y} \cdot \left(-y\right)\right)}}^{-1} \]
  6. Final simplification0.0

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

Alternatives

Alternative 1
Error0.0
Cost7040
\[{\left(\frac{1}{x + y} \cdot \left(x - y\right)\right)}^{-1} \]
Alternative 2
Error17.5
Cost856
\[\begin{array}{l} \mathbf{if}\;x \leq -3.567861787693794 \cdot 10^{+119}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -3.3476850351941332 \cdot 10^{+72}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -2.8311003836878797 \cdot 10^{-16}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2.2423002506064442 \cdot 10^{-73}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 514621.3037248732:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 6.179097722069771 \cdot 10^{+24}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 3
Error0.0
Cost448
\[\frac{x + y}{x - y} \]
Alternative 4
Error31.8
Cost64
\[1 \]

Error

Reproduce

herbie shell --seed 2022325 
(FPCore (x y)
  :name "Linear.Projection:perspective from linear-1.19.1.3, A"
  :precision binary64

  :herbie-target
  (/ 1.0 (- (/ x (+ x y)) (/ y (+ x y))))

  (/ (+ x y) (- x y)))