?

Average Error: 0.0 → 0.0
Time: 11.5s
Precision: binary64
Cost: 704

?

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

    \[\leadsto \color{blue}{\left(x - y\right) \cdot \left(\frac{2}{x + y} \cdot 0.5\right)} \]
  3. Simplified0.0

    \[\leadsto \color{blue}{0.5 \cdot \frac{2}{\frac{x + y}{x - y}}} \]
    Proof

    [Start]0.2

    \[ \left(x - y\right) \cdot \left(\frac{2}{x + y} \cdot 0.5\right) \]

    rational.json-simplify-43 [<=]0.2

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

    rational.json-simplify-2 [=>]0.2

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

    rational.json-simplify-7 [<=]0.2

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

    rational.json-simplify-35 [=>]0.2

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

    metadata-eval [=>]0.2

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

    rational.json-simplify-55 [=>]0.1

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

    metadata-eval [<=]0.1

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

    rational.json-simplify-35 [<=]0.0

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

    rational.json-simplify-7 [=>]0.0

    \[ 0.5 \cdot \frac{\color{blue}{x - y}}{\frac{x + y}{2}} \]

    rational.json-simplify-61 [<=]0.0

    \[ 0.5 \cdot \color{blue}{\frac{2}{\frac{x + y}{x - y}}} \]
  4. Final simplification0.0

    \[\leadsto 0.5 \cdot \frac{2}{\frac{x + y}{x - y}} \]

Alternatives

Alternative 1
Error17.2
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -7 \cdot 10^{-87}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{+51}:\\ \;\;\;\;2 \cdot \frac{x}{y} - 1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 2
Error0.0
Cost448
\[\frac{x - y}{x + y} \]
Alternative 3
Error17.7
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -3.2 \cdot 10^{-113}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 10^{-11}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 4
Error32.4
Cost64
\[-1 \]

Error

Reproduce?

herbie shell --seed 2023064 
(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)))