Average Error: 15.4 → 0.4
Time: 11.1s
Precision: binary64
Cost: 1744
\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ \end{array} \]
\[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
\[\begin{array}{l} t_0 := \frac{\frac{\frac{x \cdot y}{z + 1}}{z}}{z}\\ t_1 := \frac{\frac{x}{z}}{z \cdot \frac{z}{y}}\\ \mathbf{if}\;x \cdot y \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{-269}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot y \leq 4 \cdot 10^{-255}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\ \mathbf{elif}\;x \cdot y \leq 4 \cdot 10^{+289}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x y) (* (* z z) (+ z 1.0))))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (/ (/ (* x y) (+ z 1.0)) z) z))
        (t_1 (/ (/ x z) (* z (/ z y)))))
   (if (<= (* x y) (- INFINITY))
     t_1
     (if (<= (* x y) -1e-269)
       t_0
       (if (<= (* x y) 4e-255)
         (* (/ y z) (/ x z))
         (if (<= (* x y) 4e+289) t_0 t_1))))))
double code(double x, double y, double z) {
	return (x * y) / ((z * z) * (z + 1.0));
}
double code(double x, double y, double z) {
	double t_0 = (((x * y) / (z + 1.0)) / z) / z;
	double t_1 = (x / z) / (z * (z / y));
	double tmp;
	if ((x * y) <= -((double) INFINITY)) {
		tmp = t_1;
	} else if ((x * y) <= -1e-269) {
		tmp = t_0;
	} else if ((x * y) <= 4e-255) {
		tmp = (y / z) * (x / z);
	} else if ((x * y) <= 4e+289) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	return (x * y) / ((z * z) * (z + 1.0));
}
public static double code(double x, double y, double z) {
	double t_0 = (((x * y) / (z + 1.0)) / z) / z;
	double t_1 = (x / z) / (z * (z / y));
	double tmp;
	if ((x * y) <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if ((x * y) <= -1e-269) {
		tmp = t_0;
	} else if ((x * y) <= 4e-255) {
		tmp = (y / z) * (x / z);
	} else if ((x * y) <= 4e+289) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	return (x * y) / ((z * z) * (z + 1.0))
def code(x, y, z):
	t_0 = (((x * y) / (z + 1.0)) / z) / z
	t_1 = (x / z) / (z * (z / y))
	tmp = 0
	if (x * y) <= -math.inf:
		tmp = t_1
	elif (x * y) <= -1e-269:
		tmp = t_0
	elif (x * y) <= 4e-255:
		tmp = (y / z) * (x / z)
	elif (x * y) <= 4e+289:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	return Float64(Float64(x * y) / Float64(Float64(z * z) * Float64(z + 1.0)))
end
function code(x, y, z)
	t_0 = Float64(Float64(Float64(Float64(x * y) / Float64(z + 1.0)) / z) / z)
	t_1 = Float64(Float64(x / z) / Float64(z * Float64(z / y)))
	tmp = 0.0
	if (Float64(x * y) <= Float64(-Inf))
		tmp = t_1;
	elseif (Float64(x * y) <= -1e-269)
		tmp = t_0;
	elseif (Float64(x * y) <= 4e-255)
		tmp = Float64(Float64(y / z) * Float64(x / z));
	elseif (Float64(x * y) <= 4e+289)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = (x * y) / ((z * z) * (z + 1.0));
end
function tmp_2 = code(x, y, z)
	t_0 = (((x * y) / (z + 1.0)) / z) / z;
	t_1 = (x / z) / (z * (z / y));
	tmp = 0.0;
	if ((x * y) <= -Inf)
		tmp = t_1;
	elseif ((x * y) <= -1e-269)
		tmp = t_0;
	elseif ((x * y) <= 4e-255)
		tmp = (y / z) * (x / z);
	elseif ((x * y) <= 4e+289)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(x * y), $MachinePrecision] / N[(z + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / z), $MachinePrecision] / N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], (-Infinity)], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], -1e-269], t$95$0, If[LessEqual[N[(x * y), $MachinePrecision], 4e-255], N[(N[(y / z), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 4e+289], t$95$0, t$95$1]]]]]]
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\begin{array}{l}
t_0 := \frac{\frac{\frac{x \cdot y}{z + 1}}{z}}{z}\\
t_1 := \frac{\frac{x}{z}}{z \cdot \frac{z}{y}}\\
\mathbf{if}\;x \cdot y \leq -\infty:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{-269}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \cdot y \leq 4 \cdot 10^{-255}:\\
\;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\

\mathbf{elif}\;x \cdot y \leq 4 \cdot 10^{+289}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original15.4
Target4.0
Herbie0.4
\[\begin{array}{l} \mathbf{if}\;z < 249.6182814532307:\\ \;\;\;\;\frac{y \cdot \frac{x}{z}}{z + z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{y}{z}}{1 + z} \cdot x}{z}\\ \end{array} \]

Derivation

  1. Split input into 3 regimes
  2. if (*.f64 x y) < -inf.0 or 4.0000000000000002e289 < (*.f64 x y)

    1. Initial program 61.3

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Simplified19.2

      \[\leadsto \color{blue}{\frac{y}{z} \cdot \frac{x}{\mathsf{fma}\left(z, z, z\right)}} \]
      Proof
      (*.f64 (/.f64 y z) (/.f64 x (fma.f64 z z z))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 y z) (/.f64 x (fma.f64 z z (Rewrite<= *-lft-identity_binary64 (*.f64 1 z))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 y z) (/.f64 x (Rewrite<= fma-def_binary64 (+.f64 (*.f64 z z) (*.f64 1 z))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 y z) (/.f64 x (Rewrite<= distribute-rgt-in_binary64 (*.f64 z (+.f64 z 1))))): 1 points increase in error, 0 points decrease in error
      (Rewrite<= times-frac_binary64 (/.f64 (*.f64 y x) (*.f64 z (*.f64 z (+.f64 z 1))))): 60 points increase in error, 23 points decrease in error
      (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 x y)) (*.f64 z (*.f64 z (+.f64 z 1)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (*.f64 x y) (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 z z) (+.f64 z 1)))): 1 points increase in error, 0 points decrease in error
    3. Taylor expanded in z around inf 19.5

      \[\leadsto \frac{y}{z} \cdot \color{blue}{\frac{x}{{z}^{2}}} \]
    4. Simplified19.5

      \[\leadsto \frac{y}{z} \cdot \color{blue}{\frac{x}{z \cdot z}} \]
      Proof
      (/.f64 x (*.f64 z z)): 0 points increase in error, 0 points decrease in error
      (/.f64 x (Rewrite<= unpow2_binary64 (pow.f64 z 2))): 0 points increase in error, 0 points decrease in error
    5. Applied egg-rr2.3

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

    if -inf.0 < (*.f64 x y) < -9.9999999999999996e-270 or 4e-255 < (*.f64 x y) < 4.0000000000000002e289

    1. Initial program 7.4

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Applied egg-rr8.7

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

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

    if -9.9999999999999996e-270 < (*.f64 x y) < 4e-255

    1. Initial program 24.3

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

      \[\leadsto \frac{x \cdot y}{\color{blue}{{z}^{2}}} \]
    3. Simplified24.6

      \[\leadsto \frac{x \cdot y}{\color{blue}{z \cdot z}} \]
      Proof
      (*.f64 z z): 0 points increase in error, 0 points decrease in error
      (Rewrite<= unpow2_binary64 (pow.f64 z 2)): 0 points increase in error, 0 points decrease in error
    4. Applied egg-rr0.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -\infty:\\ \;\;\;\;\frac{\frac{x}{z}}{z \cdot \frac{z}{y}}\\ \mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{-269}:\\ \;\;\;\;\frac{\frac{\frac{x \cdot y}{z + 1}}{z}}{z}\\ \mathbf{elif}\;x \cdot y \leq 4 \cdot 10^{-255}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\ \mathbf{elif}\;x \cdot y \leq 4 \cdot 10^{+289}:\\ \;\;\;\;\frac{\frac{\frac{x \cdot y}{z + 1}}{z}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{z \cdot \frac{z}{y}}\\ \end{array} \]

Alternatives

Alternative 1
Error1.9
Cost7496
\[\begin{array}{l} t_0 := \frac{\frac{y}{z} \cdot \frac{x}{z + 1}}{z}\\ \mathbf{if}\;x \cdot y \leq -2 \cdot 10^{-145}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot y \leq 4 \cdot 10^{-255}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{x}{\mathsf{fma}\left(z, z, z\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error1.2
Cost1744
\[\begin{array}{l} t_0 := \frac{\frac{x \cdot y}{z \cdot \left(z + 1\right)}}{z}\\ t_1 := \frac{\frac{x}{z}}{z \cdot \frac{z}{y}}\\ \mathbf{if}\;x \cdot y \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{-269}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot y \leq 4 \cdot 10^{-255}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\ \mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+180}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error1.8
Cost1224
\[\begin{array}{l} t_0 := \frac{\frac{y}{z} \cdot \frac{x}{z + 1}}{z}\\ \mathbf{if}\;x \cdot y \leq -4 \cdot 10^{-322}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot y \leq 4 \cdot 10^{-255}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error18.2
Cost968
\[\begin{array}{l} \mathbf{if}\;x \cdot y \leq -4 \cdot 10^{-7}:\\ \;\;\;\;y \cdot \frac{x}{z \cdot z}\\ \mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{-71}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{z \cdot z}\\ \end{array} \]
Alternative 5
Error8.6
Cost840
\[\begin{array}{l} t_0 := \frac{\frac{x \cdot y}{z \cdot z}}{z}\\ \mathbf{if}\;z \leq -128978755864244.97:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{x}{z} \cdot \left(\frac{y}{z} - y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error4.1
Cost840
\[\begin{array}{l} t_0 := \frac{\frac{y}{z} \cdot \frac{x}{z}}{z}\\ \mathbf{if}\;z \leq -128978755864244.97:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{x}{z} \cdot \left(\frac{y}{z} - y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error4.4
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -128978755864244.97:\\ \;\;\;\;\frac{\frac{y}{z} \cdot \frac{x}{z}}{z}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{x}{z} \cdot \left(\frac{y}{z} - y\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{z \cdot \frac{z}{y}}\\ \end{array} \]
Alternative 8
Error18.3
Cost580
\[\begin{array}{l} \mathbf{if}\;y \leq 1.29959365575013 \cdot 10^{-10}:\\ \;\;\;\;\frac{\frac{y}{z}}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z \cdot \frac{z}{x}}\\ \end{array} \]
Alternative 9
Error17.6
Cost580
\[\begin{array}{l} \mathbf{if}\;y \leq 1.1740936379478753 \cdot 10^{-153}:\\ \;\;\;\;\frac{x}{z \cdot \frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z \cdot \frac{z}{x}}\\ \end{array} \]
Alternative 10
Error21.7
Cost448
\[\frac{\frac{y}{z}}{\frac{z}{x}} \]

Error

Reproduce

herbie shell --seed 2022301 
(FPCore (x y z)
  :name "Statistics.Distribution.Beta:$cvariance from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (if (< z 249.6182814532307) (/ (* y (/ x z)) (+ z (* z z))) (/ (* (/ (/ y z) (+ 1.0 z)) x) z))

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