Average Error: 0.0 → 0.0
Time: 3.9s
Precision: binary64
Cost: 576
\[\frac{x + y}{x - y}\]
\[\frac{1}{\frac{x - y}{x + y}}\]
\frac{x + y}{x - y}
\frac{1}{\frac{x - y}{x + y}}
(FPCore (x y) :precision binary64 (/ (+ x y) (- x y)))
(FPCore (x y) :precision binary64 (/ 1.0 (/ (- x y) (+ x y))))
double code(double x, double y) {
	return (x + y) / (x - y);
}
double code(double x, double y) {
	return 1.0 / ((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{1}{\frac{x}{x + y} - \frac{y}{x + y}}\]

Alternatives

Alternative 1
Error0.0
Cost448
\[\frac{x + y}{x - y}\]
Alternative 2
Error17.7
Cost1041
\[\begin{array}{l} \mathbf{if}\;y \leq -4.442686845312879 \cdot 10^{+90} \lor \neg \left(y \leq -4.107632137092257 \cdot 10^{-86} \lor \neg \left(y \leq -4.0647988135274745 \cdot 10^{-153}\right) \land y \leq 1.5476769801282746 \cdot 10^{-17}\right):\\ \;\;\;\;-1 - 2 \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;1 + 2 \cdot \frac{y}{x}\\ \end{array}\]
Alternative 3
Error18.0
Cost1229
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6685747854616791 \cdot 10^{+84}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -5.300995057569918 \cdot 10^{-85} \lor \neg \left(y \leq -4.0647988135274745 \cdot 10^{-153}\right) \land y \leq 3.013434194537718 \cdot 10^{-17}:\\ \;\;\;\;1 + 2 \cdot \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array}\]
Alternative 4
Error18.4
Cost1348
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6685747854616791 \cdot 10^{+84}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -6.0259921717511666 \cdot 10^{-86}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -3.059364406300126 \cdot 10^{-153}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 2.885165728068953 \cdot 10^{-17}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array}\]
Alternative 5
Error32.7
Cost64
\[1\]

Error

Derivation

  1. Initial program 0.0

    \[\frac{x + y}{x - y}\]
  2. Using strategy rm
  3. Applied clear-num_binary64_157630.0

    \[\leadsto \color{blue}{\frac{1}{\frac{x - y}{x + y}}}\]
  4. Simplified0.0

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

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

Reproduce

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