?

Average Error: 15.4 → 13.8
Time: 13.6s
Precision: binary64
Cost: 7752

?

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

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original15.4
Target4.3
Herbie13.8
\[\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) < -5.00000000000000014e-307

    1. Initial program 13.1

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

    if -5.00000000000000014e-307 < (*.f64 x y) < -0.0

    1. Initial program 26.2

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

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

      [Start]26.2

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]26.2

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

      rational_best_oopsla_all_46_json_45_simplify-7 [=>]26.2

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]26.2

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

      \[\leadsto \color{blue}{\frac{y \cdot x}{{z}^{2}} + \left(-1 \cdot \frac{y \cdot x}{z} + y \cdot x\right)} \]
    4. Simplified26.8

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

      [Start]26.8

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

      rational_best_oopsla_all_46_json_45_simplify-35 [=>]26.8

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

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

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

      [Start]16.2

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]16.2

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

      rational_best_oopsla_all_46_json_45_simplify-82 [=>]16.2

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]16.2

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

      rational_best_oopsla_all_46_json_45_simplify-92 [=>]16.2

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

    if -0.0 < (*.f64 x y)

    1. Initial program 13.7

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

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

      [Start]13.7

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]13.7

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

      rational_best_oopsla_all_46_json_45_simplify-7 [=>]13.7

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]13.7

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

      \[\leadsto \frac{x \cdot y}{\color{blue}{z \cdot \left(z \cdot z\right) + z \cdot z}} \]
    4. Applied egg-rr13.7

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

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

Alternatives

Alternative 1
Error16.7
Cost840
\[\begin{array}{l} t_0 := \frac{x \cdot y}{\left(z \cdot z\right) \cdot z}\\ \mathbf{if}\;z \leq -33:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{x \cdot y}{z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error15.4
Cost704
\[\frac{x \cdot y}{z \cdot \left(z \cdot \left(z + 1\right)\right)} \]
Alternative 3
Error15.4
Cost704
\[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
Alternative 4
Error26.2
Cost448
\[\frac{x \cdot y}{z \cdot z} \]

Error

Reproduce?

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