Average Error: 15.0 → 1.3
Time: 2.0s
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 -6.951938329975573 \cdot 10^{-40}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x}{y} + -1}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq -6.349552043791618 \cdot 10^{-274}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq 1.3773221602849323 \cdot 10^{-306}:\\ \;\;\;\;x \cdot \left(2 \cdot \frac{y}{x - y}\right)\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq 7.141867775581558 \cdot 10^{-43}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x}{y} + -1}\\ \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 -6.951938329975573 \cdot 10^{-40}:\\
\;\;\;\;\frac{x \cdot 2}{\frac{x}{y} + -1}\\

\mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq -6.349552043791618 \cdot 10^{-274}:\\
\;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\

\mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq 1.3773221602849323 \cdot 10^{-306}:\\
\;\;\;\;x \cdot \left(2 \cdot \frac{y}{x - y}\right)\\

\mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq 7.141867775581558 \cdot 10^{-43}:\\
\;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot 2}{\frac{x}{y} + -1}\\

\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))) <= -6.951938329975573e-40)) {
		VAR = (((double) (x * 2.0)) / ((double) ((x / y) + -1.0)));
	} else {
		double VAR_1;
		if (((((double) (((double) (x * 2.0)) * y)) / ((double) (x - y))) <= -6.349552043791618e-274)) {
			VAR_1 = (((double) (((double) (x * 2.0)) * y)) / ((double) (x - y)));
		} else {
			double VAR_2;
			if (((((double) (((double) (x * 2.0)) * y)) / ((double) (x - y))) <= 1.3773221602849323e-306)) {
				VAR_2 = ((double) (x * ((double) (2.0 * (y / ((double) (x - y)))))));
			} else {
				double VAR_3;
				if (((((double) (((double) (x * 2.0)) * y)) / ((double) (x - y))) <= 7.141867775581558e-43)) {
					VAR_3 = (((double) (((double) (x * 2.0)) * y)) / ((double) (x - y)));
				} else {
					VAR_3 = (((double) (x * 2.0)) / ((double) ((x / y) + -1.0)));
				}
				VAR_2 = VAR_3;
			}
			VAR_1 = VAR_2;
		}
		VAR = VAR_1;
	}
	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.0
Target0.4
Herbie1.3
\[\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 3 regimes
  2. if (/ (* (* x 2.0) y) (- x y)) < -6.9519383299755731e-40 or 7.1418677755815578e-43 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program 25.0

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
    2. Using strategy rm
    3. Applied associate-/l*0.7

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
    4. Simplified0.7

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

    if -6.9519383299755731e-40 < (/ (* (* x 2.0) y) (- x y)) < -6.3495520437916185e-274 or 1.3773221602849323e-306 < (/ (* (* x 2.0) y) (- x y)) < 7.1418677755815578e-43

    1. Initial program 0.7

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

    if -6.3495520437916185e-274 < (/ (* (* x 2.0) y) (- x y)) < 1.3773221602849323e-306

    1. Initial program 45.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq -6.951938329975573 \cdot 10^{-40}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x}{y} + -1}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq -6.349552043791618 \cdot 10^{-274}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq 1.3773221602849323 \cdot 10^{-306}:\\ \;\;\;\;x \cdot \left(2 \cdot \frac{y}{x - y}\right)\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq 7.141867775581558 \cdot 10^{-43}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x}{y} + -1}\\ \end{array}\]

Reproduce

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