Average Error: 15.4 → 1.5
Time: 2.2s
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 -1.7535824549258586 \cdot 10^{-80}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x}{y} + -1}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq -4.5581060472669115 \cdot 10^{-268} \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 4.310958904867872 \cdot 10^{-41}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(2 \cdot \frac{y}{x - y}\right)\\ \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 -1.7535824549258586 \cdot 10^{-80}:\\
\;\;\;\;\frac{x \cdot 2}{\frac{x}{y} + -1}\\

\mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq -4.5581060472669115 \cdot 10^{-268} \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 4.310958904867872 \cdot 10^{-41}:\\
\;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\

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

\end{array}
(FPCore (x y) :precision binary64 (/ (* (* x 2.0) y) (- x y)))
(FPCore (x y)
 :precision binary64
 (if (<= (/ (* (* x 2.0) y) (- x y)) -1.7535824549258586e-80)
   (/ (* x 2.0) (+ (/ x y) -1.0))
   (if (or (<= (/ (* (* x 2.0) y) (- x y)) -4.5581060472669115e-268)
           (and (not (<= (/ (* (* x 2.0) y) (- x y)) 0.0))
                (<= (/ (* (* x 2.0) y) (- x y)) 4.310958904867872e-41)))
     (/ (* (* x 2.0) y) (- x y))
     (* x (* 2.0 (/ y (- x y)))))))
double code(double x, double y) {
	return (((double) (((double) (x * 2.0)) * y)) / ((double) (x - y)));
}
double code(double x, double y) {
	double tmp;
	if (((((double) (((double) (x * 2.0)) * y)) / ((double) (x - y))) <= -1.7535824549258586e-80)) {
		tmp = (((double) (x * 2.0)) / ((double) ((x / y) + -1.0)));
	} else {
		double tmp_1;
		if ((((((double) (((double) (x * 2.0)) * y)) / ((double) (x - y))) <= -4.5581060472669115e-268) || (!((((double) (((double) (x * 2.0)) * y)) / ((double) (x - y))) <= 0.0) && ((((double) (((double) (x * 2.0)) * y)) / ((double) (x - y))) <= 4.310958904867872e-41)))) {
			tmp_1 = (((double) (((double) (x * 2.0)) * y)) / ((double) (x - y)));
		} else {
			tmp_1 = ((double) (x * ((double) (2.0 * (y / ((double) (x - y)))))));
		}
		tmp = tmp_1;
	}
	return tmp;
}

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.4
Target0.4
Herbie1.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 3 regimes
  2. if (/ (* (* x 2.0) y) (- x y)) < -1.75358245492585859e-80

    1. Initial program Error: 21.0 bits

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
    4. SimplifiedError: 1.2 bits

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

    if -1.75358245492585859e-80 < (/ (* (* x 2.0) y) (- x y)) < -4.55810604726691146e-268 or 0.0 < (/ (* (* x 2.0) y) (- x y)) < 4.310958904867872e-41

    1. Initial program Error: 0.7 bits

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

    if -4.55810604726691146e-268 < (/ (* (* x 2.0) y) (- x y)) < 0.0 or 4.310958904867872e-41 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program Error: 34.8 bits

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
    2. SimplifiedError: 2.9 bits

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq -1.7535824549258586 \cdot 10^{-80}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x}{y} + -1}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq -4.5581060472669115 \cdot 10^{-268} \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 4.310958904867872 \cdot 10^{-41}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(2 \cdot \frac{y}{x - y}\right)\\ \end{array}\]

Reproduce

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