Average Error: 0.0 → 0.0
Time: 5.4s
Precision: binary64
Cost: 13248
\[\frac{x - y}{x + y} \]
\[\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x - y}{x + y}\right)\right) \]
(FPCore (x y) :precision binary64 (/ (- x y) (+ x y)))
(FPCore (x y) :precision binary64 (log1p (expm1 (/ (- x y) (+ x y)))))
double code(double x, double y) {
	return (x - y) / (x + y);
}
double code(double x, double y) {
	return log1p(expm1(((x - y) / (x + y))));
}
public static double code(double x, double y) {
	return (x - y) / (x + y);
}
public static double code(double x, double y) {
	return Math.log1p(Math.expm1(((x - y) / (x + y))));
}
def code(x, y):
	return (x - y) / (x + y)
def code(x, y):
	return math.log1p(math.expm1(((x - y) / (x + y))))
function code(x, y)
	return Float64(Float64(x - y) / Float64(x + y))
end
function code(x, y)
	return log1p(expm1(Float64(Float64(x - y) / Float64(x + y))))
end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[Log[1 + N[(Exp[N[(N[(x - y), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]
\frac{x - y}{x + y}
\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x - y}{x + y}\right)\right)

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}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x - y}{x + y}\right)\right)} \]
  3. Final simplification0.0

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x - y}{x + y}\right)\right) \]

Alternatives

Alternative 1
Error17.3
Cost976
\[\begin{array}{l} t_0 := 1 + -2 \cdot \frac{y}{x}\\ \mathbf{if}\;y \leq -1.3260593624321216 \cdot 10^{+45}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 4.899662432827473 \cdot 10^{-99}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.182270397526762 \cdot 10^{-33}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 7.298238914889761 \cdot 10^{+80}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
Alternative 2
Error17.0
Cost976
\[\begin{array}{l} t_0 := 2 \cdot \frac{x}{y} + -1\\ t_1 := 1 + -2 \cdot \frac{y}{x}\\ \mathbf{if}\;y \leq -1.3260593624321216 \cdot 10^{+45}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4.899662432827473 \cdot 10^{-99}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.182270397526762 \cdot 10^{-33}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 7.298238914889761 \cdot 10^{+80}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error17.8
Cost856
\[\begin{array}{l} \mathbf{if}\;y \leq -1.3260593624321216 \cdot 10^{+45}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 4.899662432827473 \cdot 10^{-99}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 2.182270397526762 \cdot 10^{-33}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 153162955687192540:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 8 \cdot 10^{+39}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 7.298238914889761 \cdot 10^{+80}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
Alternative 4
Error0.0
Cost448
\[\frac{x - y}{x + y} \]
Alternative 5
Error31.9
Cost64
\[1 \]

Error

Reproduce

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