Average Error: 14.8 → 5.7
Time: 2.6s
Precision: binary64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \leq 6.427361026581062 \cdot 10^{+268}:\\ \;\;\;\;\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(2 \cdot \left(\frac{1}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \left(\sqrt[3]{x} \cdot \frac{y}{\sqrt[3]{x - y}}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(2 \cdot y\right)}{x - y}\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;x \leq 6.427361026581062 \cdot 10^{+268}:\\
\;\;\;\;\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(2 \cdot \left(\frac{1}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \left(\sqrt[3]{x} \cdot \frac{y}{\sqrt[3]{x - y}}\right)\right)\right)\\

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

\end{array}
(FPCore (x y) :precision binary64 (/ (* (* x 2.0) y) (- x y)))
(FPCore (x y)
 :precision binary64
 (if (<= x 6.427361026581062e+268)
   (*
    (* (cbrt x) (cbrt x))
    (*
     2.0
     (*
      (/ 1.0 (* (cbrt (- x y)) (cbrt (- x y))))
      (* (cbrt x) (/ y (cbrt (- 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 ((x <= 6.427361026581062e+268)) {
		tmp = ((double) (((double) (((double) cbrt(x)) * ((double) cbrt(x)))) * ((double) (2.0 * ((double) ((1.0 / ((double) (((double) cbrt(((double) (x - y)))) * ((double) cbrt(((double) (x - y))))))) * ((double) (((double) cbrt(x)) * (y / ((double) cbrt(((double) (x - y)))))))))))));
	} else {
		tmp = (((double) (x * ((double) (2.0 * y)))) / ((double) (x - y)));
	}
	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

Original14.8
Target0.3
Herbie5.7
\[\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 < 6.4273610265810619e268

    1. Initial program Error: 14.3 bits

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

      \[\leadsto \color{blue}{x \cdot \left(2 \cdot \frac{y}{x - y}\right)}\]
    3. Using strategy rm
    4. Applied add-cube-cbrtError: 7.3 bits

      \[\leadsto \color{blue}{\left(\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}\right)} \cdot \left(2 \cdot \frac{y}{x - y}\right)\]
    5. Applied associate-*l*Error: 7.3 bits

      \[\leadsto \color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(\sqrt[3]{x} \cdot \left(2 \cdot \frac{y}{x - y}\right)\right)}\]
    6. SimplifiedError: 7.3 bits

      \[\leadsto \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \color{blue}{\left(2 \cdot \left(\frac{y}{x - y} \cdot \sqrt[3]{x}\right)\right)}\]
    7. Using strategy rm
    8. Applied add-cube-cbrtError: 7.1 bits

      \[\leadsto \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(2 \cdot \left(\frac{y}{\color{blue}{\left(\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}\right) \cdot \sqrt[3]{x - y}}} \cdot \sqrt[3]{x}\right)\right)\]
    9. Applied *-un-lft-identityError: 7.1 bits

      \[\leadsto \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(2 \cdot \left(\frac{\color{blue}{1 \cdot y}}{\left(\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}\right) \cdot \sqrt[3]{x - y}} \cdot \sqrt[3]{x}\right)\right)\]
    10. Applied times-fracError: 7.1 bits

      \[\leadsto \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(2 \cdot \left(\color{blue}{\left(\frac{1}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \frac{y}{\sqrt[3]{x - y}}\right)} \cdot \sqrt[3]{x}\right)\right)\]
    11. Applied associate-*l*Error: 4.9 bits

      \[\leadsto \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(2 \cdot \color{blue}{\left(\frac{1}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \left(\frac{y}{\sqrt[3]{x - y}} \cdot \sqrt[3]{x}\right)\right)}\right)\]
    12. SimplifiedError: 4.9 bits

      \[\leadsto \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(2 \cdot \left(\frac{1}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \color{blue}{\left(\sqrt[3]{x} \cdot \frac{y}{\sqrt[3]{x - y}}\right)}\right)\right)\]

    if 6.4273610265810619e268 < x

    1. Initial program Error: 29.9 bits

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

      \[\leadsto \color{blue}{x \cdot \left(2 \cdot \frac{y}{x - y}\right)}\]
    3. Using strategy rm
    4. Applied associate-*r/Error: 29.2 bits

      \[\leadsto x \cdot \color{blue}{\frac{2 \cdot y}{x - y}}\]
    5. Applied associate-*r/Error: 29.4 bits

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 6.427361026581062 \cdot 10^{+268}:\\ \;\;\;\;\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(2 \cdot \left(\frac{1}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \left(\sqrt[3]{x} \cdot \frac{y}{\sqrt[3]{x - y}}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(2 \cdot y\right)}{x - y}\\ \end{array}\]

Reproduce

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