Average Error: 0.0 → 0.0
Time: 2.0s
Precision: binary64
Cost: 448
\[\frac{x - y}{x + y}\]
\[\frac{x - y}{x + y}\]
\frac{x - y}{x + y}
\frac{x - y}{x + y}
(FPCore (x y) :precision binary64 (/ (- x y) (+ x y)))
(FPCore (x y) :precision binary64 (/ (- x y) (+ x y)))
double code(double x, double y) {
	return (x - y) / (x + y);
}
double code(double x, double y) {
	return (x - y) / (x + y);
}

Error

Bits error versus x

Bits error versus y

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}\]

Alternatives

Alternative 1
Error17.1
Cost1041
\[\begin{array}{l} \mathbf{if}\;x \leq -7.447499202074567 \cdot 10^{+89} \lor \neg \left(x \leq 3.4010946694147876 \cdot 10^{-96} \lor \neg \left(x \leq 9.74969812626511 \cdot 10^{-12}\right) \land x \leq 4.9187347626101874 \cdot 10^{+39}\right):\\ \;\;\;\;1 - 2 \cdot \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;-1 + 2 \cdot \frac{x}{y}\\ \end{array}\]
Alternative 2
Error17.4
Cost1041
\[\begin{array}{l} \mathbf{if}\;x \leq -7.659727394055092 \cdot 10^{+89} \lor \neg \left(x \leq 1.9351779201160667 \cdot 10^{-95} \lor \neg \left(x \leq 1.0002652120941761 \cdot 10^{-11}\right) \land x \leq 6.191369215281873 \cdot 10^{+41}\right):\\ \;\;\;\;1 - 2 \cdot \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array}\]
Alternative 3
Error17.8
Cost1348
\[\begin{array}{l} \mathbf{if}\;x \leq -1.1501120665853518 \cdot 10^{+90}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.7232515495395666 \cdot 10^{-95}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 4.5547354228815765 \cdot 10^{-11}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 4.412444982343629 \cdot 10^{+40}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]
Alternative 4
Error32.6
Cost64
\[1\]

Error

Derivation

  1. Initial program 0.0

    \[\frac{x - y}{x + y}\]
  2. Simplified0.0

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

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

Reproduce

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