Average Error: 15.1 → 1.9
Time: 28.1s
Precision: binary64
Cost: 1224
\[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
\[\begin{array}{l} t_0 := \frac{\frac{y}{z + 1}}{z} \cdot \frac{x}{z}\\ \mathbf{if}\;x \cdot y \leq 10^{-296}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot y \leq 10^{+244}:\\ \;\;\;\;\frac{\frac{\frac{y \cdot x}{z}}{z}}{z + 1}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x y) (* (* z z) (+ z 1.0))))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (/ (/ y (+ z 1.0)) z) (/ x z))))
   (if (<= (* x y) 1e-296)
     t_0
     (if (<= (* x y) 1e+244) (/ (/ (/ (* y x) z) z) (+ z 1.0)) t_0))))
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 = ((y / (z + 1.0)) / z) * (x / z);
	double tmp;
	if ((x * y) <= 1e-296) {
		tmp = t_0;
	} else if ((x * y) <= 1e+244) {
		tmp = (((y * x) / z) / z) / (z + 1.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * y) / ((z * z) * (z + 1.0d0))
end function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((y / (z + 1.0d0)) / z) * (x / z)
    if ((x * y) <= 1d-296) then
        tmp = t_0
    else if ((x * y) <= 1d+244) then
        tmp = (((y * x) / z) / z) / (z + 1.0d0)
    else
        tmp = t_0
    end if
    code = tmp
end function
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 = ((y / (z + 1.0)) / z) * (x / z);
	double tmp;
	if ((x * y) <= 1e-296) {
		tmp = t_0;
	} else if ((x * y) <= 1e+244) {
		tmp = (((y * x) / z) / z) / (z + 1.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	return (x * y) / ((z * z) * (z + 1.0))
def code(x, y, z):
	t_0 = ((y / (z + 1.0)) / z) * (x / z)
	tmp = 0
	if (x * y) <= 1e-296:
		tmp = t_0
	elif (x * y) <= 1e+244:
		tmp = (((y * x) / z) / z) / (z + 1.0)
	else:
		tmp = t_0
	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(y / Float64(z + 1.0)) / z) * Float64(x / z))
	tmp = 0.0
	if (Float64(x * y) <= 1e-296)
		tmp = t_0;
	elseif (Float64(x * y) <= 1e+244)
		tmp = Float64(Float64(Float64(Float64(y * x) / z) / z) / Float64(z + 1.0));
	else
		tmp = t_0;
	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 = ((y / (z + 1.0)) / z) * (x / z);
	tmp = 0.0;
	if ((x * y) <= 1e-296)
		tmp = t_0;
	elseif ((x * y) <= 1e+244)
		tmp = (((y * x) / z) / z) / (z + 1.0);
	else
		tmp = t_0;
	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[(y / N[(z + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], 1e-296], t$95$0, If[LessEqual[N[(x * y), $MachinePrecision], 1e+244], N[(N[(N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision] / z), $MachinePrecision] / N[(z + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\begin{array}{l}
t_0 := \frac{\frac{y}{z + 1}}{z} \cdot \frac{x}{z}\\
\mathbf{if}\;x \cdot y \leq 10^{-296}:\\
\;\;\;\;t_0\\

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original15.1
Target4.2
Herbie1.9
\[\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 2 regimes
  2. if (*.f64 x y) < 1e-296 or 1.00000000000000007e244 < (*.f64 x y)

    1. Initial program 19.5

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

      \[\leadsto \color{blue}{\left(\frac{y}{z + 1} \cdot \frac{1}{z}\right) \cdot \frac{x}{z}} \]
    3. Applied egg-rr2.8

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

    if 1e-296 < (*.f64 x y) < 1.00000000000000007e244

    1. Initial program 7.0

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z \cdot \mathsf{fma}\left(z, z, z\right)}} \]
      Proof
    3. Applied egg-rr0.2

      \[\leadsto \color{blue}{\frac{\frac{\frac{x \cdot y}{z}}{z}}{z + 1}} \]
    4. Simplified0.2

      \[\leadsto \color{blue}{\frac{\frac{\frac{y \cdot x}{z}}{z}}{z + 1}} \]
      Proof
  3. Recombined 2 regimes into one program.

Alternatives

Alternative 1
Error18.0
Cost1228
\[\begin{array}{l} t_0 := \frac{y}{z \cdot z} \cdot x\\ \mathbf{if}\;x \cdot y \leq -6 \cdot 10^{+19}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot y \leq 0:\\ \;\;\;\;\left(y \cdot \frac{1}{z}\right) \cdot \frac{x}{z}\\ \mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+90}:\\ \;\;\;\;\frac{y \cdot \frac{x}{z}}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error3.2
Cost1224
\[\begin{array}{l} t_0 := \frac{\frac{y}{z + 1}}{z} \cdot \frac{x}{z}\\ \mathbf{if}\;x \cdot y \leq 2 \cdot 10^{-55}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot y \leq 10^{+244}:\\ \;\;\;\;\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error19.1
Cost976
\[\begin{array}{l} t_0 := \frac{y}{z \cdot z} \cdot x\\ \mathbf{if}\;x \leq -1.45 \cdot 10^{-11}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -5 \cdot 10^{-302}:\\ \;\;\;\;\frac{x}{z} \cdot \left(\frac{y}{z} - y\right)\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-114}:\\ \;\;\;\;\frac{\frac{x}{z}}{z} \cdot y\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-92}:\\ \;\;\;\;\frac{\frac{y}{z}}{z} \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error5.9
Cost968
\[\begin{array}{l} t_0 := x \cdot \frac{\frac{y}{1 + z}}{z \cdot z}\\ \mathbf{if}\;z \leq -5.5 \cdot 10^{-100}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-66}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error5.5
Cost968
\[\begin{array}{l} t_0 := x \cdot \frac{\frac{\frac{y}{z}}{z}}{z + 1}\\ \mathbf{if}\;z \leq -3.15 \cdot 10^{-108}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{-66}:\\ \;\;\;\;\left(y \cdot \frac{1}{z}\right) \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error5.3
Cost968
\[\begin{array}{l} \mathbf{if}\;z \leq -1.65 \cdot 10^{-94}:\\ \;\;\;\;\frac{y}{z + 1} \cdot \frac{x}{z \cdot z}\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{-66}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\frac{\frac{y}{z}}{z}}{z + 1}\\ \end{array} \]
Alternative 7
Error18.2
Cost712
\[\begin{array}{l} t_0 := \frac{x}{z \cdot z} \cdot y\\ \mathbf{if}\;z \leq -3.2 \cdot 10^{-95}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-92}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error18.1
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{-94}:\\ \;\;\;\;\frac{x}{z \cdot z} \cdot y\\ \mathbf{elif}\;z \leq 8.8 \cdot 10^{-64}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z \cdot z} \cdot x\\ \end{array} \]
Alternative 9
Error18.8
Cost712
\[\begin{array}{l} t_0 := \frac{\frac{x}{z}}{z} \cdot y\\ \mathbf{if}\;y \leq -5 \cdot 10^{-12}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{+89}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 10
Error3.4
Cost704
\[\frac{\frac{y}{z + 1}}{z} \cdot \frac{x}{z} \]
Alternative 11
Error24.2
Cost448
\[\frac{x}{z \cdot z} \cdot y \]
Alternative 12
Error49.0
Cost384
\[-\frac{y \cdot x}{z} \]
Alternative 13
Error46.4
Cost384
\[\left(-y\right) \cdot \frac{x}{z} \]

Error

Reproduce

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