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

\mathbf{elif}\;y \leq 7 \cdot 10^{+15}:\\
\;\;\;\;\frac{x \cdot y}{y + 1}\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.7
Target0.0
Herbie0.1
\[\begin{array}{l} \mathbf{if}\;y < -3693.8482788297247:\\ \;\;\;\;\frac{x}{y \cdot y} - \left(\frac{x}{y} - x\right)\\ \mathbf{elif}\;y < 6799310503.41891:\\ \;\;\;\;\frac{x \cdot y}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot y} - \left(\frac{x}{y} - x\right)\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. if y < -6.4999999999999994e32 or 7e15 < y

    1. Initial program 16.7

      \[\frac{x \cdot y}{y + 1} \]
    2. Taylor expanded in y around inf 0.0

      \[\leadsto \color{blue}{x} \]

    if -6.4999999999999994e32 < y < 7e15

    1. Initial program 0.2

      \[\frac{x \cdot y}{y + 1} \]
  3. Recombined 2 regimes into one program.

Alternatives

Alternative 1
Error0.0
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -200000000:\\ \;\;\;\;x - \frac{x}{y}\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{+15}:\\ \;\;\;\;\frac{x}{y + 1} \cdot y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error1.1
Cost584
\[\begin{array}{l} t_0 := x - \frac{x}{y}\\ \mathbf{if}\;y \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.3:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error1.5
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error31.7
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2023010 
(FPCore (x y)
  :name "Diagrams.Trail:splitAtParam  from diagrams-lib-1.3.0.3, B"
  :precision binary64

  :herbie-target
  (if (< y -3693.8482788297247) (- (/ x (* y y)) (- (/ x y) x)) (if (< y 6799310503.41891) (/ (* x y) (+ y 1.0)) (- (/ x (* y y)) (- (/ x y) x))))

  (/ (* x y) (+ y 1.0)))