Average Error: 15.1 → 0.1
Time: 5.8s
Precision: binary64
Cost: 840
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -9.95622796599085 \cdot 10^{+40}:\\ \;\;\;\;\left(x + x\right) \cdot \frac{y}{x - y}\\ \mathbf{elif}\;y \leq 2.898915618176099 \cdot 10^{+20}:\\ \;\;\;\;y \cdot \frac{x + x}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + x}{\frac{x}{y} + -1}\\ \end{array} \]
(FPCore (x y) :precision binary64 (/ (* (* x 2.0) y) (- x y)))
(FPCore (x y)
 :precision binary64
 (if (<= y -9.95622796599085e+40)
   (* (+ x x) (/ y (- x y)))
   (if (<= y 2.898915618176099e+20)
     (* y (/ (+ x x) (- x y)))
     (/ (+ x x) (+ (/ x y) -1.0)))))
double code(double x, double y) {
	return ((x * 2.0) * y) / (x - y);
}
double code(double x, double y) {
	double tmp;
	if (y <= -9.95622796599085e+40) {
		tmp = (x + x) * (y / (x - y));
	} else if (y <= 2.898915618176099e+20) {
		tmp = y * ((x + x) / (x - y));
	} else {
		tmp = (x + x) / ((x / y) + -1.0);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = ((x * 2.0d0) * y) / (x - y)
end function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-9.95622796599085d+40)) then
        tmp = (x + x) * (y / (x - y))
    else if (y <= 2.898915618176099d+20) then
        tmp = y * ((x + x) / (x - y))
    else
        tmp = (x + x) / ((x / y) + (-1.0d0))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	return ((x * 2.0) * y) / (x - y);
}
public static double code(double x, double y) {
	double tmp;
	if (y <= -9.95622796599085e+40) {
		tmp = (x + x) * (y / (x - y));
	} else if (y <= 2.898915618176099e+20) {
		tmp = y * ((x + x) / (x - y));
	} else {
		tmp = (x + x) / ((x / y) + -1.0);
	}
	return tmp;
}
def code(x, y):
	return ((x * 2.0) * y) / (x - y)
def code(x, y):
	tmp = 0
	if y <= -9.95622796599085e+40:
		tmp = (x + x) * (y / (x - y))
	elif y <= 2.898915618176099e+20:
		tmp = y * ((x + x) / (x - y))
	else:
		tmp = (x + x) / ((x / y) + -1.0)
	return tmp
function code(x, y)
	return Float64(Float64(Float64(x * 2.0) * y) / Float64(x - y))
end
function code(x, y)
	tmp = 0.0
	if (y <= -9.95622796599085e+40)
		tmp = Float64(Float64(x + x) * Float64(y / Float64(x - y)));
	elseif (y <= 2.898915618176099e+20)
		tmp = Float64(y * Float64(Float64(x + x) / Float64(x - y)));
	else
		tmp = Float64(Float64(x + x) / Float64(Float64(x / y) + -1.0));
	end
	return tmp
end
function tmp = code(x, y)
	tmp = ((x * 2.0) * y) / (x - y);
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -9.95622796599085e+40)
		tmp = (x + x) * (y / (x - y));
	elseif (y <= 2.898915618176099e+20)
		tmp = y * ((x + x) / (x - y));
	else
		tmp = (x + x) / ((x / y) + -1.0);
	end
	tmp_2 = tmp;
end
code[x_, y_] := N[(N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := If[LessEqual[y, -9.95622796599085e+40], N[(N[(x + x), $MachinePrecision] * N[(y / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.898915618176099e+20], N[(y * N[(N[(x + x), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + x), $MachinePrecision] / N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;y \leq -9.95622796599085 \cdot 10^{+40}:\\
\;\;\;\;\left(x + x\right) \cdot \frac{y}{x - y}\\

\mathbf{elif}\;y \leq 2.898915618176099 \cdot 10^{+20}:\\
\;\;\;\;y \cdot \frac{x + x}{x - y}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + x}{\frac{x}{y} + -1}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original15.1
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 < 83645045635564430:\\ \;\;\;\;\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 < -9.95622796599084989e40

    1. Initial program 18.4

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
    2. Applied egg-rr0.0

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

    if -9.95622796599084989e40 < y < 289891561817609896000

    1. Initial program 12.7

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

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

    if 289891561817609896000 < y

    1. Initial program 17.6

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
    2. Applied egg-rr14.3

      \[\leadsto \color{blue}{\frac{x + x}{x - y} \cdot y} \]
    3. Applied egg-rr0.1

      \[\leadsto \color{blue}{\frac{x + x}{\frac{x - y}{y}}} \]
    4. Taylor expanded in x around 0 0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.95622796599085 \cdot 10^{+40}:\\ \;\;\;\;\left(x + x\right) \cdot \frac{y}{x - y}\\ \mathbf{elif}\;y \leq 2.898915618176099 \cdot 10^{+20}:\\ \;\;\;\;y \cdot \frac{x + x}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + x}{\frac{x}{y} + -1}\\ \end{array} \]

Alternatives

Alternative 1
Error4.0
Cost840
\[\begin{array}{l} t_0 := \frac{x + x}{\frac{x}{y} + -1}\\ \mathbf{if}\;y \leq -3.1481975723521372 \cdot 10^{-201}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.122022002838058 \cdot 10^{-155}:\\ \;\;\;\;y \cdot 2\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error3.9
Cost840
\[\begin{array}{l} t_0 := \frac{x + x}{\frac{x}{y} + -1}\\ \mathbf{if}\;y \leq -3.1481975723521372 \cdot 10^{-201}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.122022002838058 \cdot 10^{-155}:\\ \;\;\;\;2 \cdot \left(y + y \cdot \frac{y}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error0.1
Cost840
\[\begin{array}{l} t_0 := \frac{x + x}{\frac{x}{y} + -1}\\ \mathbf{if}\;y \leq -9.95622796599085 \cdot 10^{+40}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.898915618176099 \cdot 10^{+20}:\\ \;\;\;\;y \cdot \frac{x + x}{x - y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error16.0
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -4.868936317937288 \cdot 10^{+59}:\\ \;\;\;\;x \cdot -2\\ \mathbf{elif}\;y \leq 26047.069786415846:\\ \;\;\;\;y \cdot 2\\ \mathbf{else}:\\ \;\;\;\;x \cdot -2\\ \end{array} \]
Alternative 5
Error31.9
Cost192
\[x \cdot -2 \]

Error

Reproduce

herbie shell --seed 2022300 
(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 83645045635564430.0) (/ (* x 2.0) (/ (- x y) y)) (* (/ (* 2.0 x) (- x y)) y)))

  (/ (* (* x 2.0) y) (- x y)))