Average Error: 15.5 → 0.5
Time: 2.3s
Precision: binary64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq -\infty \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq -4.2173653667467924 \cdot 10^{-305} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq 0\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq 3.7297874078970674 \cdot 10^{-56}\right):\\ \;\;\;\;x \cdot \left(2 \cdot \frac{y}{x - y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq -\infty \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq -4.2173653667467924 \cdot 10^{-305} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq 0\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq 3.7297874078970674 \cdot 10^{-56}\right):\\
\;\;\;\;x \cdot \left(2 \cdot \frac{y}{x - y}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\

\end{array}
double code(double x, double y) {
	return (((double) (((double) (x * 2.0)) * y)) / ((double) (x - y)));
}
double code(double x, double y) {
	double VAR;
	if ((((((double) (((double) (x * 2.0)) * y)) / ((double) (x - y))) <= ((double) -(((double) INFINITY)))) || !(((((double) (((double) (x * 2.0)) * y)) / ((double) (x - y))) <= -4.2173653667467924e-305) || (!((((double) (((double) (x * 2.0)) * y)) / ((double) (x - y))) <= 0.0) && ((((double) (((double) (x * 2.0)) * y)) / ((double) (x - y))) <= 3.7297874078970674e-56))))) {
		VAR = ((double) (x * ((double) (2.0 * (y / ((double) (x - y)))))));
	} else {
		VAR = (((double) (((double) (x * 2.0)) * y)) / ((double) (x - y)));
	}
	return VAR;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original15.5
Target0.4
Herbie0.5
\[\begin{array}{l} \mathbf{if}\;x < -1.7210442634149447 \cdot 10^{+81}:\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \mathbf{elif}\;x < 8.364504563556443 \cdot 10^{+16}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (/ (* (* x 2.0) y) (- x y)) < -inf.0 or -4.21736536674679242e-305 < (/ (* (* x 2.0) y) (- x y)) < 0.0 or 3.7297874078970674e-56 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program 42.4

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
    2. Simplified0.5

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

    if -inf.0 < (/ (* (* x 2.0) y) (- x y)) < -4.21736536674679242e-305 or 0.0 < (/ (* (* x 2.0) y) (- x y)) < 3.7297874078970674e-56

    1. Initial program 0.5

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq -\infty \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq -4.2173653667467924 \cdot 10^{-305} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq 0\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq 3.7297874078970674 \cdot 10^{-56}\right):\\ \;\;\;\;x \cdot \left(2 \cdot \frac{y}{x - y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \end{array}\]

Reproduce

herbie shell --seed 2020196 
(FPCore (x y)
  :name "Linear.Projection:perspective from linear-1.19.1.3, B"
  :precision binary64

  :herbie-target
  (if (< x -1.7210442634149447e+81) (* (/ (* 2.0 x) (- x y)) y) (if (< x 8.364504563556443e+16) (/ (* x 2.0) (/ (- x y) y)) (* (/ (* 2.0 x) (- x y)) y)))

  (/ (* (* x 2.0) y) (- x y)))