Average Error: 14.9 → 0.6
Time: 1.7s
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.0634875567936728 \cdot 10^{-05} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq -2.510506970217685 \cdot 10^{-301} \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 1.064869663315659 \cdot 10^{+54}\right):\\ \;\;\;\;\frac{x \cdot 2}{\frac{x}{y} + -1}\\ \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 -1.0634875567936728 \cdot 10^{-05} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq -2.510506970217685 \cdot 10^{-301} \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 1.064869663315659 \cdot 10^{+54}\right):\\
\;\;\;\;\frac{x \cdot 2}{\frac{x}{y} + -1}\\

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

\end{array}
(FPCore (x y) :precision binary64 (/ (* (* x 2.0) y) (- x y)))
(FPCore (x y)
 :precision binary64
 (if (or (<= (/ (* (* x 2.0) y) (- x y)) -1.0634875567936728e-05)
         (not
          (or (<= (/ (* (* x 2.0) y) (- x y)) -2.510506970217685e-301)
              (and (not (<= (/ (* (* x 2.0) y) (- x y)) 0.0))
                   (<= (/ (* (* x 2.0) y) (- x y)) 1.064869663315659e+54)))))
   (/ (* x 2.0) (+ (/ x y) -1.0))
   (/ (* (* 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 VAR;
	if ((((((double) (((double) (x * 2.0)) * y)) / ((double) (x - y))) <= -1.0634875567936728e-05) || !(((((double) (((double) (x * 2.0)) * y)) / ((double) (x - y))) <= -2.510506970217685e-301) || (!((((double) (((double) (x * 2.0)) * y)) / ((double) (x - y))) <= 0.0) && ((((double) (((double) (x * 2.0)) * y)) / ((double) (x - y))) <= 1.064869663315659e+54))))) {
		VAR = (((double) (x * 2.0)) / ((double) ((x / y) + -1.0)));
	} 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

Original14.9
Target0.4
Herbie0.6
\[\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)) < -1.06348755679367282e-5 or -2.5105069702176851e-301 < (/ (* (* x 2.0) y) (- x y)) < 0.0 or 1.064869663315659e54 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program 43.0

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

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

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

    if -1.06348755679367282e-5 < (/ (* (* x 2.0) y) (- x y)) < -2.5105069702176851e-301 or 0.0 < (/ (* (* x 2.0) y) (- x y)) < 1.064869663315659e54

    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.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq -1.0634875567936728 \cdot 10^{-05} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \leq -2.510506970217685 \cdot 10^{-301} \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 1.064869663315659 \cdot 10^{+54}\right):\\ \;\;\;\;\frac{x \cdot 2}{\frac{x}{y} + -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \end{array}\]

Reproduce

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