?

Average Error: 14.4 → 13.0
Time: 27.5s
Precision: binary64
Cost: 7560

?

\[ \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} \mathbf{if}\;x \cdot y \leq -2 \cdot 10^{-289}:\\ \;\;\;\;\frac{x \cdot y}{z \cdot \left({z}^{2} + z\right)}\\ \mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{-319}:\\ \;\;\;\;\left(\frac{x}{{z}^{2}} - \frac{x}{z}\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x y) (* (* z z) (+ z 1.0))))
(FPCore (x y z)
 :precision binary64
 (if (<= (* x y) -2e-289)
   (/ (* x y) (* z (+ (pow z 2.0) z)))
   (if (<= (* x y) 5e-319)
     (* (- (/ x (pow z 2.0)) (/ x z)) y)
     (/ (* x y) (* (* z z) (+ z 1.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 tmp;
	if ((x * y) <= -2e-289) {
		tmp = (x * y) / (z * (pow(z, 2.0) + z));
	} else if ((x * y) <= 5e-319) {
		tmp = ((x / pow(z, 2.0)) - (x / z)) * y;
	} else {
		tmp = (x * y) / ((z * z) * (z + 1.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) :: tmp
    if ((x * y) <= (-2d-289)) then
        tmp = (x * y) / (z * ((z ** 2.0d0) + z))
    else if ((x * y) <= 5d-319) then
        tmp = ((x / (z ** 2.0d0)) - (x / z)) * y
    else
        tmp = (x * y) / ((z * z) * (z + 1.0d0))
    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 tmp;
	if ((x * y) <= -2e-289) {
		tmp = (x * y) / (z * (Math.pow(z, 2.0) + z));
	} else if ((x * y) <= 5e-319) {
		tmp = ((x / Math.pow(z, 2.0)) - (x / z)) * y;
	} else {
		tmp = (x * y) / ((z * z) * (z + 1.0));
	}
	return tmp;
}
def code(x, y, z):
	return (x * y) / ((z * z) * (z + 1.0))
def code(x, y, z):
	tmp = 0
	if (x * y) <= -2e-289:
		tmp = (x * y) / (z * (math.pow(z, 2.0) + z))
	elif (x * y) <= 5e-319:
		tmp = ((x / math.pow(z, 2.0)) - (x / z)) * y
	else:
		tmp = (x * y) / ((z * z) * (z + 1.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)
	tmp = 0.0
	if (Float64(x * y) <= -2e-289)
		tmp = Float64(Float64(x * y) / Float64(z * Float64((z ^ 2.0) + z)));
	elseif (Float64(x * y) <= 5e-319)
		tmp = Float64(Float64(Float64(x / (z ^ 2.0)) - Float64(x / z)) * y);
	else
		tmp = Float64(Float64(x * y) / Float64(Float64(z * z) * Float64(z + 1.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)
	tmp = 0.0;
	if ((x * y) <= -2e-289)
		tmp = (x * y) / (z * ((z ^ 2.0) + z));
	elseif ((x * y) <= 5e-319)
		tmp = ((x / (z ^ 2.0)) - (x / z)) * y;
	else
		tmp = (x * y) / ((z * z) * (z + 1.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_] := If[LessEqual[N[(x * y), $MachinePrecision], -2e-289], N[(N[(x * y), $MachinePrecision] / N[(z * N[(N[Power[z, 2.0], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 5e-319], N[(N[(N[(x / N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision] - N[(x / z), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{-289}:\\
\;\;\;\;\frac{x \cdot y}{z \cdot \left({z}^{2} + z\right)}\\

\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{-319}:\\
\;\;\;\;\left(\frac{x}{{z}^{2}} - \frac{x}{z}\right) \cdot y\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original14.4
Target3.9
Herbie13.0
\[\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) < -2e-289

    1. Initial program 12.6

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

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

      [Start]12.6

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

      rational.json-simplify-2 [=>]12.6

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

      rational.json-simplify-43 [=>]12.6

      \[ \frac{x \cdot y}{\color{blue}{z \cdot \left(z \cdot \left(z + 1\right)\right)}} \]
    3. Taylor expanded in z around 0 12.6

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

    if -2e-289 < (*.f64 x y) < 4.9999937e-319

    1. Initial program 23.6

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

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

      [Start]23.6

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

      rational.json-simplify-2 [=>]23.6

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

      rational.json-simplify-43 [=>]23.6

      \[ \frac{x \cdot y}{\color{blue}{z \cdot \left(z \cdot \left(z + 1\right)\right)}} \]
    3. Taylor expanded in z around 0 23.7

      \[\leadsto \color{blue}{\frac{y \cdot x}{{z}^{2}} + -1 \cdot \frac{y \cdot x}{z}} \]
    4. Simplified23.7

      \[\leadsto \color{blue}{\frac{y \cdot x}{{z}^{2}} + \left(-\frac{y \cdot x}{z}\right)} \]
      Proof

      [Start]23.7

      \[ \frac{y \cdot x}{{z}^{2}} + -1 \cdot \frac{y \cdot x}{z} \]

      rational.json-simplify-2 [=>]23.7

      \[ \frac{y \cdot x}{{z}^{2}} + \color{blue}{\frac{y \cdot x}{z} \cdot -1} \]

      rational.json-simplify-9 [=>]23.7

      \[ \frac{y \cdot x}{{z}^{2}} + \color{blue}{\left(-\frac{y \cdot x}{z}\right)} \]
    5. Taylor expanded in y around 0 15.6

      \[\leadsto \color{blue}{\left(\frac{x}{{z}^{2}} - \frac{x}{z}\right) \cdot y} \]

    if 4.9999937e-319 < (*.f64 x y)

    1. Initial program 12.3

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification13.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -2 \cdot 10^{-289}:\\ \;\;\;\;\frac{x \cdot y}{z \cdot \left({z}^{2} + z\right)}\\ \mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{-319}:\\ \;\;\;\;\left(\frac{x}{{z}^{2}} - \frac{x}{z}\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}\\ \end{array} \]

Alternatives

Alternative 1
Error13.0
Cost7560
\[\begin{array}{l} \mathbf{if}\;x \cdot y \leq -2 \cdot 10^{-289}:\\ \;\;\;\;\frac{x \cdot y}{z \cdot \left(z \cdot \left(z + 1\right)\right)}\\ \mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{-319}:\\ \;\;\;\;\left(\frac{x}{{z}^{2}} - \frac{x}{z}\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}\\ \end{array} \]
Alternative 2
Error13.0
Cost7304
\[\begin{array}{l} t_0 := \frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}\\ \mathbf{if}\;x \cdot y \leq -4 \cdot 10^{-304}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{-319}:\\ \;\;\;\;\frac{x}{{z}^{2}} \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error21.6
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;0 \cdot x\\ \mathbf{elif}\;z \leq 2.25 \cdot 10^{+55}:\\ \;\;\;\;\frac{x \cdot y}{z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;0 \cdot x\\ \end{array} \]
Alternative 4
Error14.4
Cost704
\[\frac{x \cdot y}{z \cdot \left(z \cdot \left(z + 1\right)\right)} \]
Alternative 5
Error14.4
Cost704
\[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
Alternative 6
Error33.6
Cost192
\[0 \cdot x \]

Error

Reproduce?

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