Average Error: 14.9 → 0.9
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} \le -1.02230823992003717 \cdot 10^{-98} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -4.82054295086426792 \cdot 10^{-307} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -0.0\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 6.22780731280235451 \cdot 10^{108}\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} \le -1.02230823992003717 \cdot 10^{-98} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -4.82054295086426792 \cdot 10^{-307} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -0.0\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 6.22780731280235451 \cdot 10^{108}\right):\\
\;\;\;\;\frac{x \cdot 2}{\frac{x}{y} + -1}\\

\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))) <= -1.0223082399200372e-98) || !(((((double) (((double) (x * 2.0)) * y)) / ((double) (x - y))) <= -4.820542950864268e-307) || (!((((double) (((double) (x * 2.0)) * y)) / ((double) (x - y))) <= -0.0) && ((((double) (((double) (x * 2.0)) * y)) / ((double) (x - y))) <= 6.227807312802355e+108))))) {
		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.9
\[\begin{array}{l} \mathbf{if}\;x \lt -1.7210442634149447 \cdot 10^{81}:\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \mathbf{elif}\;x \lt 83645045635564432:\\ \;\;\;\;\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.02230823992003717e-98 or -4.82054295086426792e-307 < (/ (* (* x 2.0) y) (- x y)) < -0.0 or 6.22780731280235451e108 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program 36.5

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

      \[\leadsto \color{blue}{x \cdot \left(2 \cdot \frac{y}{x - y}\right)}\]
    3. Using strategy rm
    4. Applied clear-num1.4

      \[\leadsto x \cdot \left(2 \cdot \color{blue}{\frac{1}{\frac{x - y}{y}}}\right)\]
    5. Simplified1.4

      \[\leadsto x \cdot \left(2 \cdot \frac{1}{\color{blue}{\frac{x}{y} + -1}}\right)\]
    6. Using strategy rm
    7. Applied un-div-inv1.4

      \[\leadsto x \cdot \color{blue}{\frac{2}{\frac{x}{y} + -1}}\]
    8. Applied associate-*r/1.4

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

    if -1.02230823992003717e-98 < (/ (* (* x 2.0) y) (- x y)) < -4.82054295086426792e-307 or -0.0 < (/ (* (* x 2.0) y) (- x y)) < 6.22780731280235451e108

    1. Initial program 0.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.02230823992003717 \cdot 10^{-98} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -4.82054295086426792 \cdot 10^{-307} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -0.0\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 6.22780731280235451 \cdot 10^{108}\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 2020182 
(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)))