Average Error: 14.4 → 0.7
Time: 9.2s
Precision: 64
$2 \cdot \frac{x \cdot y}{x - y}$
$\begin{array}{l} \mathbf{if}\;\frac{y \cdot x}{x - y} = -\infty:\\ \;\;\;\;\left(x \cdot \frac{y}{x - y}\right) \cdot 2\\ \mathbf{elif}\;\frac{y \cdot x}{x - y} \le -3.110153045338136 \cdot 10^{-292}:\\ \;\;\;\;2 \cdot \frac{y \cdot x}{x - y}\\ \mathbf{elif}\;\frac{y \cdot x}{x - y} \le -0.0:\\ \;\;\;\;\left(x \cdot \frac{y}{x - y}\right) \cdot 2\\ \mathbf{elif}\;\frac{y \cdot x}{x - y} \le 1.835830023822163 \cdot 10^{-28}:\\ \;\;\;\;2 \cdot \frac{y \cdot x}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{x - y}{y}} \cdot 2\\ \end{array}$
2 \cdot \frac{x \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;\frac{y \cdot x}{x - y} = -\infty:\\
\;\;\;\;\left(x \cdot \frac{y}{x - y}\right) \cdot 2\\

\mathbf{elif}\;\frac{y \cdot x}{x - y} \le -3.110153045338136 \cdot 10^{-292}:\\
\;\;\;\;2 \cdot \frac{y \cdot x}{x - y}\\

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

\mathbf{elif}\;\frac{y \cdot x}{x - y} \le 1.835830023822163 \cdot 10^{-28}:\\
\;\;\;\;2 \cdot \frac{y \cdot x}{x - y}\\

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

\end{array}
double f(double x, double y) {
double r8684662 = 2.0;
double r8684663 = x;
double r8684664 = y;
double r8684665 = r8684663 * r8684664;
double r8684666 = r8684663 - r8684664;
double r8684667 = r8684665 / r8684666;
double r8684668 = r8684662 * r8684667;
return r8684668;
}


double f(double x, double y) {
double r8684669 = y;
double r8684670 = x;
double r8684671 = r8684669 * r8684670;
double r8684672 = r8684670 - r8684669;
double r8684673 = r8684671 / r8684672;
double r8684674 = -inf.0;
bool r8684675 = r8684673 <= r8684674;
double r8684676 = r8684669 / r8684672;
double r8684677 = r8684670 * r8684676;
double r8684678 = 2.0;
double r8684679 = r8684677 * r8684678;
double r8684680 = -3.110153045338136e-292;
bool r8684681 = r8684673 <= r8684680;
double r8684682 = r8684678 * r8684673;
double r8684683 = -0.0;
bool r8684684 = r8684673 <= r8684683;
double r8684685 = 1.835830023822163e-28;
bool r8684686 = r8684673 <= r8684685;
double r8684687 = r8684672 / r8684669;
double r8684688 = r8684670 / r8684687;
double r8684689 = r8684688 * r8684678;
double r8684690 = r8684686 ? r8684682 : r8684689;
double r8684691 = r8684684 ? r8684679 : r8684690;
double r8684692 = r8684681 ? r8684682 : r8684691;
double r8684693 = r8684675 ? r8684679 : r8684692;
return r8684693;
}



# Try it out

Your Program's Arguments

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 3 regimes
2. ## if (/ (* x y) (- x y)) < -inf.0 or -3.110153045338136e-292 < (/ (* x y) (- x y)) < -0.0

1. Initial program 54.4

$2 \cdot \frac{x \cdot y}{x - y}$
2. Using strategy rm
3. Applied *-un-lft-identity54.4

$\leadsto 2 \cdot \frac{x \cdot y}{\color{blue}{1 \cdot \left(x - y\right)}}$
4. Applied times-frac2.1

$\leadsto 2 \cdot \color{blue}{\left(\frac{x}{1} \cdot \frac{y}{x - y}\right)}$
5. Simplified2.1

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

## if -inf.0 < (/ (* x y) (- x y)) < -3.110153045338136e-292 or -0.0 < (/ (* x y) (- x y)) < 1.835830023822163e-28

1. Initial program 0.5

$2 \cdot \frac{x \cdot y}{x - y}$

## if 1.835830023822163e-28 < (/ (* x y) (- x y))

1. Initial program 26.3

$2 \cdot \frac{x \cdot y}{x - y}$
2. Using strategy rm
3. Applied associate-/l*0.1

$\leadsto 2 \cdot \color{blue}{\frac{x}{\frac{x - y}{y}}}$
3. Recombined 3 regimes into one program.
4. Final simplification0.7

$\leadsto \begin{array}{l} \mathbf{if}\;\frac{y \cdot x}{x - y} = -\infty:\\ \;\;\;\;\left(x \cdot \frac{y}{x - y}\right) \cdot 2\\ \mathbf{elif}\;\frac{y \cdot x}{x - y} \le -3.110153045338136 \cdot 10^{-292}:\\ \;\;\;\;2 \cdot \frac{y \cdot x}{x - y}\\ \mathbf{elif}\;\frac{y \cdot x}{x - y} \le -0.0:\\ \;\;\;\;\left(x \cdot \frac{y}{x - y}\right) \cdot 2\\ \mathbf{elif}\;\frac{y \cdot x}{x - y} \le 1.835830023822163 \cdot 10^{-28}:\\ \;\;\;\;2 \cdot \frac{y \cdot x}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{x - y}{y}} \cdot 2\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (x y)
:name "2*((x*y)/(x-y))"
(* 2 (/ (* x y) (- x y))))