Average Error: 0.0 → 0.0
Time: 45.2s
Precision: binary64
Cost: 7296
\[\frac{x + y}{x - y} \]
\[{\left(\frac{x}{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 (+ 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 / (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 / (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 / (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 / (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(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 / (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[(x + y), $MachinePrecision]), $MachinePrecision] + N[(y * N[(-1.0 / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]
\frac{x + y}{x - y}
{\left(\frac{x}{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-rr32.0

    \[\leadsto \color{blue}{\frac{1}{\sqrt{x - y}} \cdot \frac{x + y}{\sqrt{x - y}}} \]
  3. Simplified32.0

    \[\leadsto \color{blue}{\frac{\frac{x + y}{\sqrt{x - y}}}{\sqrt{x - y}}} \]
    Proof
    (/.f64 (/.f64 (+.f64 x y) (sqrt.f64 (-.f64 x y))) (sqrt.f64 (-.f64 x y))): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= *-lft-identity_binary64 (*.f64 1 (/.f64 (+.f64 x y) (sqrt.f64 (-.f64 x y))))) (sqrt.f64 (-.f64 x y))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 1 (sqrt.f64 (-.f64 x y))) (/.f64 (+.f64 x y) (sqrt.f64 (-.f64 x y))))): 8 points increase in error, 17 points decrease in error
  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. Applied egg-rr0.0

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

    \[\leadsto {\left(\color{blue}{\frac{x}{x + y}} + \frac{1}{x + y} \cdot \left(-y\right)\right)}^{-1} \]
    Proof
    (/.f64 x (+.f64 x y)): 0 points increase in error, 0 points decrease in error
    (Rewrite<= +-lft-identity_binary64 (+.f64 0 (/.f64 x (+.f64 x y)))): 0 points increase in error, 0 points decrease in error
  8. Final simplification0.0

    \[\leadsto {\left(\frac{x}{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
Error16.7
Cost1240
\[\begin{array}{l} t_0 := 1 + 2 \cdot \frac{y}{x}\\ \mathbf{if}\;x \leq -5 \cdot 10^{+106}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.3 \cdot 10^{+72}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -2.6 \cdot 10^{-16}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{-72}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 2200000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{+24}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error16.4
Cost1240
\[\begin{array}{l} t_0 := 1 + 2 \cdot \frac{y}{x}\\ t_1 := -1 + -2 \cdot \frac{x}{y}\\ \mathbf{if}\;x \leq -5 \cdot 10^{+106}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.05 \cdot 10^{+72}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.1 \cdot 10^{-19}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 6.3 \cdot 10^{-72}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 40000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{+24}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error17.1
Cost856
\[\begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{+106}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -2 \cdot 10^{+72}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -5.8 \cdot 10^{-17}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-73}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 1300000000:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{+24}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 5
Error0.0
Cost448
\[\frac{x + y}{x - y} \]
Alternative 6
Error32.6
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)))