Average Error: 15.0 → 0.1
Time: 7.0s
Precision: binary64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;y \leq -128989.54692959297:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x}{y} + -1}\\ \mathbf{elif}\;y \leq 1.0804958672835222 \cdot 10^{-12}:\\ \;\;\;\;y \cdot \frac{x \cdot 2}{x - y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y \cdot 2}{x - y}\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;y \leq -128989.54692959297:\\
\;\;\;\;\frac{x \cdot 2}{\frac{x}{y} + -1}\\

\mathbf{elif}\;y \leq 1.0804958672835222 \cdot 10^{-12}:\\
\;\;\;\;y \cdot \frac{x \cdot 2}{x - y}\\

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

\end{array}
(FPCore (x y) :precision binary64 (/ (* (* x 2.0) y) (- x y)))
(FPCore (x y)
 :precision binary64
 (if (<= y -128989.54692959297)
   (/ (* x 2.0) (+ (/ x y) -1.0))
   (if (<= y 1.0804958672835222e-12)
     (* y (/ (* x 2.0) (- x y)))
     (* x (/ (* y 2.0) (- x y))))))
double code(double x, double y) {
	return ((x * 2.0) * y) / (x - y);
}
double code(double x, double y) {
	double tmp;
	if (y <= -128989.54692959297) {
		tmp = (x * 2.0) / ((x / y) + -1.0);
	} else if (y <= 1.0804958672835222e-12) {
		tmp = y * ((x * 2.0) / (x - y));
	} else {
		tmp = x * ((y * 2.0) / (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

Original15.0
Target0.3
Herbie0.1
\[\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 y < -128989.54692959297

    1. Initial program 16.6

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

      \[\leadsto \color{blue}{x \cdot \frac{2 \cdot y}{x - y}}\]
    3. Using strategy rm
    4. Applied pow1_binary64_96870.2

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

      \[\leadsto \color{blue}{{x}^{1}} \cdot {\left(\frac{2 \cdot y}{x - y}\right)}^{1}\]
    6. Applied pow-prod-down_binary64_96970.2

      \[\leadsto \color{blue}{{\left(x \cdot \frac{2 \cdot y}{x - y}\right)}^{1}}\]
    7. Simplified0.1

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

    if -128989.54692959297 < y < 1.0804958672835222e-12

    1. Initial program 13.8

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

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

    if 1.0804958672835222e-12 < y

    1. Initial program 15.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -128989.54692959297:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x}{y} + -1}\\ \mathbf{elif}\;y \leq 1.0804958672835222 \cdot 10^{-12}:\\ \;\;\;\;y \cdot \frac{x \cdot 2}{x - y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y \cdot 2}{x - y}\\ \end{array}\]

Reproduce

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