?

Average Error: 19.9 → 9.5
Time: 9.9s
Precision: binary64
Cost: 1352

?

\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ \end{array} \]
\[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
\[\begin{array}{l} \mathbf{if}\;x \leq -2.45 \cdot 10^{+92}:\\ \;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\ \mathbf{elif}\;x \leq -1 \cdot 10^{-146}:\\ \;\;\;\;\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y + y \cdot y}\\ \end{array} \]
(FPCore (x y)
 :precision binary64
 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
(FPCore (x y)
 :precision binary64
 (if (<= x -2.45e+92)
   (/ y (* (+ 1.0 x) x))
   (if (<= x -1e-146)
     (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0)))
     (/ x (+ y (* y y))))))
double code(double x, double y) {
	return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
double code(double x, double y) {
	double tmp;
	if (x <= -2.45e+92) {
		tmp = y / ((1.0 + x) * x);
	} else if (x <= -1e-146) {
		tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
	} else {
		tmp = x / (y + (y * y));
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x * y) / (((x + y) * (x + y)) * ((x + 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 (x <= (-2.45d+92)) then
        tmp = y / ((1.0d0 + x) * x)
    else if (x <= (-1d-146)) then
        tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
    else
        tmp = x / (y + (y * y))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
public static double code(double x, double y) {
	double tmp;
	if (x <= -2.45e+92) {
		tmp = y / ((1.0 + x) * x);
	} else if (x <= -1e-146) {
		tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
	} else {
		tmp = x / (y + (y * y));
	}
	return tmp;
}
def code(x, y):
	return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
def code(x, y):
	tmp = 0
	if x <= -2.45e+92:
		tmp = y / ((1.0 + x) * x)
	elif x <= -1e-146:
		tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
	else:
		tmp = x / (y + (y * y))
	return tmp
function code(x, y)
	return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0)))
end
function code(x, y)
	tmp = 0.0
	if (x <= -2.45e+92)
		tmp = Float64(y / Float64(Float64(1.0 + x) * x));
	elseif (x <= -1e-146)
		tmp = Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0)));
	else
		tmp = Float64(x / Float64(y + Float64(y * y)));
	end
	return tmp
end
function tmp = code(x, y)
	tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -2.45e+92)
		tmp = y / ((1.0 + x) * x);
	elseif (x <= -1e-146)
		tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
	else
		tmp = x / (y + (y * y));
	end
	tmp_2 = tmp;
end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := If[LessEqual[x, -2.45e+92], N[(y / N[(N[(1.0 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1e-146], N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(y + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\begin{array}{l}
\mathbf{if}\;x \leq -2.45 \cdot 10^{+92}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\

\mathbf{elif}\;x \leq -1 \cdot 10^{-146}:\\
\;\;\;\;\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{y + y \cdot y}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original19.9
Target0.1
Herbie9.5
\[\frac{\frac{\frac{x}{\left(y + 1\right) + x}}{y + x}}{\frac{1}{\frac{y}{y + x}}} \]

Derivation?

  1. Split input into 3 regimes
  2. if x < -2.4500000000000001e92

    1. Initial program 26.0

      \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
    2. Taylor expanded in y around 0 10.5

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

    if -2.4500000000000001e92 < x < -1.00000000000000003e-146

    1. Initial program 9.5

      \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]

    if -1.00000000000000003e-146 < x

    1. Initial program 22.3

      \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
    2. Taylor expanded in x around 0 8.7

      \[\leadsto \color{blue}{\frac{x}{y \cdot \left(1 + y\right)}} \]
    3. Simplified8.7

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

      [Start]8.7

      \[ \frac{x}{y \cdot \left(1 + y\right)} \]

      rational_best_oopsla_all_46_json_45_simplify-37 [=>]8.7

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]8.7

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

      rational_best_oopsla_all_46_json_45_simplify-52 [=>]8.7

      \[ \frac{x}{\color{blue}{y} + y \cdot y} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.5

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

Alternatives

Alternative 1
Error22.0
Cost580
\[\begin{array}{l} \mathbf{if}\;y \leq 2.02 \cdot 10^{-163}:\\ \;\;\;\;\frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y + y \cdot y}\\ \end{array} \]
Alternative 2
Error13.8
Cost580
\[\begin{array}{l} \mathbf{if}\;x \leq -2.05 \cdot 10^{-24}:\\ \;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y + y \cdot y}\\ \end{array} \]
Alternative 3
Error35.6
Cost324
\[\begin{array}{l} \mathbf{if}\;y \leq 2.02 \cdot 10^{-163}:\\ \;\;\;\;\frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 4
Error46.9
Cost192
\[\frac{x}{y} \]
Alternative 5
Error61.6
Cost128
\[-y \]
Alternative 6
Error61.8
Cost64
\[1 \]

Error

Reproduce?

herbie shell --seed 2023090 
(FPCore (x y)
  :name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, A"
  :precision binary64

  :herbie-target
  (/ (/ (/ x (+ (+ y 1.0) x)) (+ y x)) (/ 1.0 (/ y (+ y x))))

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