Average Error: 0.0 → 0.0
Time: 9.0s
Precision: binary64
Cost: 832
\[\frac{x - y}{x + y} \]
\[\frac{x}{x + y} + \frac{-1}{\frac{x + y}{y}} \]
(FPCore (x y) :precision binary64 (/ (- x y) (+ x y)))
(FPCore (x y) :precision binary64 (+ (/ x (+ x y)) (/ -1.0 (/ (+ x y) y))))
double code(double x, double y) {
	return (x - y) / (x + y);
}
double code(double x, double y) {
	return (x / (x + y)) + (-1.0 / ((x + y) / y));
}
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)) + ((-1.0d0) / ((x + y) / y))
end function
public static double code(double x, double y) {
	return (x - y) / (x + y);
}
public static double code(double x, double y) {
	return (x / (x + y)) + (-1.0 / ((x + y) / y));
}
def code(x, y):
	return (x - y) / (x + y)
def code(x, y):
	return (x / (x + y)) + (-1.0 / ((x + y) / y))
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(-1.0 / Float64(Float64(x + y) / y)))
end
function tmp = code(x, y)
	tmp = (x - y) / (x + y);
end
function tmp = code(x, y)
	tmp = (x / (x + y)) + (-1.0 / ((x + y) / y));
end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[(N[(x + y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x - y}{x + y}
\frac{x}{x + y} + \frac{-1}{\frac{x + y}{y}}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 0.0

    \[\frac{x - y}{x + y} \]
  2. Applied egg-rr0.0

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

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

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

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

Alternatives

Alternative 1
Error16.4
Cost1240
\[\begin{array}{l} t_0 := 2 \cdot \frac{x}{y} + -1\\ \mathbf{if}\;y \leq -1.12 \cdot 10^{+95}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -4 \cdot 10^{+62}:\\ \;\;\;\;\frac{x}{x + y}\\ \mathbf{elif}\;y \leq -1.22 \cdot 10^{+39}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{-52}:\\ \;\;\;\;1 + -2 \cdot \frac{y}{x}\\ \mathbf{elif}\;y \leq 600000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 9 \cdot 10^{+19}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error16.6
Cost1176
\[\begin{array}{l} t_0 := \frac{-y}{x + y}\\ \mathbf{if}\;y \leq -6.2 \cdot 10^{+96}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -4.4 \cdot 10^{+62}:\\ \;\;\;\;\frac{x}{x + y}\\ \mathbf{elif}\;y \leq -1.14 \cdot 10^{+39}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 3 \cdot 10^{-45}:\\ \;\;\;\;1 - \frac{y}{x}\\ \mathbf{elif}\;y \leq 38000000:\\ \;\;\;\;\frac{x}{y} + -1\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{+19}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error16.3
Cost1176
\[\begin{array}{l} t_0 := \frac{-y}{x + y}\\ \mathbf{if}\;y \leq -1.3 \cdot 10^{+93}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{+61}:\\ \;\;\;\;\frac{x}{x + y}\\ \mathbf{elif}\;y \leq -1 \cdot 10^{+40}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{-45}:\\ \;\;\;\;1 + -2 \cdot \frac{y}{x}\\ \mathbf{elif}\;y \leq 27000000:\\ \;\;\;\;\frac{x}{y} + -1\\ \mathbf{elif}\;y \leq 1.36 \cdot 10^{+20}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error16.5
Cost1112
\[\begin{array}{l} t_0 := \frac{x}{y} + -1\\ \mathbf{if}\;y \leq -6.2 \cdot 10^{+93}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -3.5 \cdot 10^{+68}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -9 \cdot 10^{+39}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{-45}:\\ \;\;\;\;1 - \frac{y}{x}\\ \mathbf{elif}\;y \leq 215000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.15 \cdot 10^{+20}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error16.5
Cost1112
\[\begin{array}{l} t_0 := \frac{x}{y} + -1\\ \mathbf{if}\;y \leq -1.2 \cdot 10^{+93}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -4.2 \cdot 10^{+61}:\\ \;\;\;\;\frac{x}{x + y}\\ \mathbf{elif}\;y \leq -2.8 \cdot 10^{+38}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{-45}:\\ \;\;\;\;1 - \frac{y}{x}\\ \mathbf{elif}\;y \leq 88000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{+20}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error16.9
Cost856
\[\begin{array}{l} \mathbf{if}\;y \leq -1.2 \cdot 10^{+93}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -4 \cdot 10^{+62}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -1.15 \cdot 10^{+39}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 9.2 \cdot 10^{-46}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 200000000:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 1.75 \cdot 10^{+20}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
Alternative 7
Error16.8
Cost856
\[\begin{array}{l} \mathbf{if}\;y \leq -8.6 \cdot 10^{+94}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -4.4 \cdot 10^{+62}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -5.5 \cdot 10^{+38}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 3 \cdot 10^{-45}:\\ \;\;\;\;1 - \frac{y}{x}\\ \mathbf{elif}\;y \leq 61000000:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 5 \cdot 10^{+19}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
Alternative 8
Error0.0
Cost704
\[\frac{x}{x + y} - \frac{y}{x + y} \]
Alternative 9
Error0.0
Cost448
\[\frac{x - y}{x + y} \]
Alternative 10
Error32.2
Cost64
\[-1 \]

Error

Reproduce

herbie shell --seed 2022329 
(FPCore (x y)
  :name "Data.Colour.RGB:hslsv from colour-2.3.3, D"
  :precision binary64

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

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