Statistics.Distribution.Beta:$cvariance from math-functions-0.1.5.2

Percentage Accurate: 83.2% → 96.3%
Time: 11.8s
Alternatives: 9
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \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))))
double code(double x, double y, double z) {
	return (x * y) / ((z * z) * (z + 1.0));
}
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
public static double code(double x, double y, double z) {
	return (x * y) / ((z * z) * (z + 1.0));
}
def code(x, y, z):
	return (x * y) / ((z * z) * (z + 1.0))
function code(x, y, z)
	return Float64(Float64(x * y) / Float64(Float64(z * z) * Float64(z + 1.0)))
end
function tmp = code(x, y, z)
	tmp = (x * y) / ((z * z) * (z + 1.0));
end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 83.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \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))))
double code(double x, double y, double z) {
	return (x * y) / ((z * z) * (z + 1.0));
}
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
public static double code(double x, double y, double z) {
	return (x * y) / ((z * z) * (z + 1.0));
}
def code(x, y, z):
	return (x * y) / ((z * z) * (z + 1.0))
function code(x, y, z)
	return Float64(Float64(x * y) / Float64(Float64(z * z) * Float64(z + 1.0)))
end
function tmp = code(x, y, z)
	tmp = (x * y) / ((z * z) * (z + 1.0));
end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\end{array}

Alternative 1: 96.3% accurate, 1.0× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \frac{y}{z} \cdot \frac{\frac{x}{z}}{z + 1} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z) :precision binary64 (* (/ y z) (/ (/ x z) (+ z 1.0))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	return (y / z) * ((x / z) / (z + 1.0));
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (y / z) * ((x / z) / (z + 1.0d0))
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	return (y / z) * ((x / z) / (z + 1.0));
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	return (y / z) * ((x / z) / (z + 1.0))
x, y, z = sort([x, y, z])
function code(x, y, z)
	return Float64(Float64(y / z) * Float64(Float64(x / z) / Float64(z + 1.0)))
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
	tmp = (y / z) * ((x / z) / (z + 1.0));
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := N[(N[(y / z), $MachinePrecision] * N[(N[(x / z), $MachinePrecision] / N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\frac{y}{z} \cdot \frac{\frac{x}{z}}{z + 1}
\end{array}
Derivation
  1. Initial program 85.0%

    \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. *-commutative85.0%

      \[\leadsto \frac{\color{blue}{y \cdot x}}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. frac-times87.9%

      \[\leadsto \color{blue}{\frac{y}{z \cdot z} \cdot \frac{x}{z + 1}} \]
    3. associate-*l/87.3%

      \[\leadsto \color{blue}{\frac{y \cdot \frac{x}{z + 1}}{z \cdot z}} \]
    4. times-frac97.2%

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

    \[\leadsto \color{blue}{\frac{y}{z} \cdot \frac{\frac{x}{z + 1}}{z}} \]
  5. Taylor expanded in x around 0 95.6%

    \[\leadsto \frac{y}{z} \cdot \color{blue}{\frac{x}{z \cdot \left(1 + z\right)}} \]
  6. Step-by-step derivation
    1. associate-/r*97.2%

      \[\leadsto \frac{y}{z} \cdot \color{blue}{\frac{\frac{x}{z}}{1 + z}} \]
    2. +-commutative97.2%

      \[\leadsto \frac{y}{z} \cdot \frac{\frac{x}{z}}{\color{blue}{z + 1}} \]
  7. Simplified97.2%

    \[\leadsto \frac{y}{z} \cdot \color{blue}{\frac{\frac{x}{z}}{z + 1}} \]
  8. Final simplification97.2%

    \[\leadsto \frac{y}{z} \cdot \frac{\frac{x}{z}}{z + 1} \]
  9. Add Preprocessing

Alternative 2: 94.7% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 4.2 \cdot 10^{-15}\right):\\ \;\;\;\;\frac{y}{z} \cdot \frac{\frac{x}{z}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot \frac{x}{z}}{z}\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -1.0) (not (<= z 4.2e-15)))
   (* (/ y z) (/ (/ x z) z))
   (/ (* y (/ x z)) z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.0) || !(z <= 4.2e-15)) {
		tmp = (y / z) * ((x / z) / z);
	} else {
		tmp = (y * (x / z)) / z;
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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 ((z <= (-1.0d0)) .or. (.not. (z <= 4.2d-15))) then
        tmp = (y / z) * ((x / z) / z)
    else
        tmp = (y * (x / z)) / z
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.0) || !(z <= 4.2e-15)) {
		tmp = (y / z) * ((x / z) / z);
	} else {
		tmp = (y * (x / z)) / z;
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if (z <= -1.0) or not (z <= 4.2e-15):
		tmp = (y / z) * ((x / z) / z)
	else:
		tmp = (y * (x / z)) / z
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if ((z <= -1.0) || !(z <= 4.2e-15))
		tmp = Float64(Float64(y / z) * Float64(Float64(x / z) / z));
	else
		tmp = Float64(Float64(y * Float64(x / z)) / z);
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -1.0) || ~((z <= 4.2e-15)))
		tmp = (y / z) * ((x / z) / z);
	else
		tmp = (y * (x / z)) / z;
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 4.2e-15]], $MachinePrecision]], N[(N[(y / z), $MachinePrecision] * N[(N[(x / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 4.2 \cdot 10^{-15}\right):\\
\;\;\;\;\frac{y}{z} \cdot \frac{\frac{x}{z}}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1 or 4.19999999999999962e-15 < z

    1. Initial program 89.7%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative89.7%

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

        \[\leadsto \color{blue}{\frac{y}{z \cdot z} \cdot \frac{x}{z + 1}} \]
      3. associate-*l/94.3%

        \[\leadsto \color{blue}{\frac{y \cdot \frac{x}{z + 1}}{z \cdot z}} \]
      4. times-frac98.3%

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

      \[\leadsto \color{blue}{\frac{y}{z} \cdot \frac{\frac{x}{z + 1}}{z}} \]
    5. Taylor expanded in z around inf 94.9%

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

    if -1 < z < 4.19999999999999962e-15

    1. Initial program 80.7%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Step-by-step derivation
      1. *-commutative80.7%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
      2. associate-*l/80.5%

        \[\leadsto \color{blue}{\frac{y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \cdot x} \]
      3. *-commutative80.5%

        \[\leadsto \color{blue}{x \cdot \frac{y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}} \]
      4. sqr-neg80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(\left(-z\right) \cdot \left(-z\right)\right)} \cdot \left(z + 1\right)} \]
      5. *-commutative80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(z + 1\right) \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)}} \]
      6. distribute-rgt1-in80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(-z\right) \cdot \left(-z\right) + z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)}} \]
      7. sqr-neg80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot z} + z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)} \]
      8. fma-def80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\mathsf{fma}\left(z, z, z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)\right)}} \]
      9. sqr-neg80.5%

        \[\leadsto x \cdot \frac{y}{\mathsf{fma}\left(z, z, z \cdot \color{blue}{\left(z \cdot z\right)}\right)} \]
      10. cube-unmult80.5%

        \[\leadsto x \cdot \frac{y}{\mathsf{fma}\left(z, z, \color{blue}{{z}^{3}}\right)} \]
    3. Simplified80.5%

      \[\leadsto \color{blue}{x \cdot \frac{y}{\mathsf{fma}\left(z, z, {z}^{3}\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-def80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot z + {z}^{3}}} \]
      2. associate-*r/80.7%

        \[\leadsto \color{blue}{\frac{x \cdot y}{z \cdot z + {z}^{3}}} \]
      3. *-commutative80.7%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{z \cdot z + {z}^{3}} \]
      4. cube-mult80.7%

        \[\leadsto \frac{y \cdot x}{z \cdot z + \color{blue}{z \cdot \left(z \cdot z\right)}} \]
      5. distribute-rgt1-in80.7%

        \[\leadsto \frac{y \cdot x}{\color{blue}{\left(z + 1\right) \cdot \left(z \cdot z\right)}} \]
      6. *-commutative80.7%

        \[\leadsto \frac{y \cdot x}{\color{blue}{\left(z \cdot z\right) \cdot \left(z + 1\right)}} \]
      7. frac-times80.5%

        \[\leadsto \color{blue}{\frac{y}{z \cdot z} \cdot \frac{x}{z + 1}} \]
      8. associate-/r*89.8%

        \[\leadsto \color{blue}{\frac{\frac{y}{z}}{z}} \cdot \frac{x}{z + 1} \]
      9. associate-*l/96.4%

        \[\leadsto \color{blue}{\frac{\frac{y}{z} \cdot \frac{x}{z + 1}}{z}} \]
    6. Applied egg-rr96.4%

      \[\leadsto \color{blue}{\frac{\frac{y}{z} \cdot \frac{x}{z + 1}}{z}} \]
    7. Taylor expanded in z around 0 88.7%

      \[\leadsto \frac{\color{blue}{\frac{x \cdot y}{z}}}{z} \]
    8. Step-by-step derivation
      1. associate-*l/94.1%

        \[\leadsto \frac{\color{blue}{\frac{x}{z} \cdot y}}{z} \]
      2. *-commutative94.1%

        \[\leadsto \frac{\color{blue}{y \cdot \frac{x}{z}}}{z} \]
    9. Simplified94.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 4.2 \cdot 10^{-15}\right):\\ \;\;\;\;\frac{y}{z} \cdot \frac{\frac{x}{z}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot \frac{x}{z}}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 95.3% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 4.2 \cdot 10^{-15}\right):\\ \;\;\;\;\frac{\frac{y}{z} \cdot \frac{x}{z}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot \left(\frac{x}{z} - x\right)}{z}\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -1.0) (not (<= z 4.2e-15)))
   (/ (* (/ y z) (/ x z)) z)
   (/ (* y (- (/ x z) x)) z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.0) || !(z <= 4.2e-15)) {
		tmp = ((y / z) * (x / z)) / z;
	} else {
		tmp = (y * ((x / z) - x)) / z;
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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 ((z <= (-1.0d0)) .or. (.not. (z <= 4.2d-15))) then
        tmp = ((y / z) * (x / z)) / z
    else
        tmp = (y * ((x / z) - x)) / z
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.0) || !(z <= 4.2e-15)) {
		tmp = ((y / z) * (x / z)) / z;
	} else {
		tmp = (y * ((x / z) - x)) / z;
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if (z <= -1.0) or not (z <= 4.2e-15):
		tmp = ((y / z) * (x / z)) / z
	else:
		tmp = (y * ((x / z) - x)) / z
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if ((z <= -1.0) || !(z <= 4.2e-15))
		tmp = Float64(Float64(Float64(y / z) * Float64(x / z)) / z);
	else
		tmp = Float64(Float64(y * Float64(Float64(x / z) - x)) / z);
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -1.0) || ~((z <= 4.2e-15)))
		tmp = ((y / z) * (x / z)) / z;
	else
		tmp = (y * ((x / z) - x)) / z;
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 4.2e-15]], $MachinePrecision]], N[(N[(N[(y / z), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(y * N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 4.2 \cdot 10^{-15}\right):\\
\;\;\;\;\frac{\frac{y}{z} \cdot \frac{x}{z}}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1 or 4.19999999999999962e-15 < z

    1. Initial program 89.7%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Step-by-step derivation
      1. *-commutative89.7%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
      2. associate-*l/95.5%

        \[\leadsto \color{blue}{\frac{y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \cdot x} \]
      3. *-commutative95.5%

        \[\leadsto \color{blue}{x \cdot \frac{y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}} \]
      4. sqr-neg95.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(\left(-z\right) \cdot \left(-z\right)\right)} \cdot \left(z + 1\right)} \]
      5. *-commutative95.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(z + 1\right) \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)}} \]
      6. distribute-rgt1-in71.2%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(-z\right) \cdot \left(-z\right) + z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)}} \]
      7. sqr-neg71.2%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot z} + z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)} \]
      8. fma-def95.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\mathsf{fma}\left(z, z, z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)\right)}} \]
      9. sqr-neg95.5%

        \[\leadsto x \cdot \frac{y}{\mathsf{fma}\left(z, z, z \cdot \color{blue}{\left(z \cdot z\right)}\right)} \]
      10. cube-unmult95.5%

        \[\leadsto x \cdot \frac{y}{\mathsf{fma}\left(z, z, \color{blue}{{z}^{3}}\right)} \]
    3. Simplified95.5%

      \[\leadsto \color{blue}{x \cdot \frac{y}{\mathsf{fma}\left(z, z, {z}^{3}\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-def71.2%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot z + {z}^{3}}} \]
      2. associate-*r/67.0%

        \[\leadsto \color{blue}{\frac{x \cdot y}{z \cdot z + {z}^{3}}} \]
      3. *-commutative67.0%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{z \cdot z + {z}^{3}} \]
      4. cube-mult67.0%

        \[\leadsto \frac{y \cdot x}{z \cdot z + \color{blue}{z \cdot \left(z \cdot z\right)}} \]
      5. distribute-rgt1-in89.7%

        \[\leadsto \frac{y \cdot x}{\color{blue}{\left(z + 1\right) \cdot \left(z \cdot z\right)}} \]
      6. *-commutative89.7%

        \[\leadsto \frac{y \cdot x}{\color{blue}{\left(z \cdot z\right) \cdot \left(z + 1\right)}} \]
      7. frac-times95.8%

        \[\leadsto \color{blue}{\frac{y}{z \cdot z} \cdot \frac{x}{z + 1}} \]
      8. associate-/r*99.1%

        \[\leadsto \color{blue}{\frac{\frac{y}{z}}{z}} \cdot \frac{x}{z + 1} \]
      9. associate-*l/98.4%

        \[\leadsto \color{blue}{\frac{\frac{y}{z} \cdot \frac{x}{z + 1}}{z}} \]
    6. Applied egg-rr98.4%

      \[\leadsto \color{blue}{\frac{\frac{y}{z} \cdot \frac{x}{z + 1}}{z}} \]
    7. Taylor expanded in z around inf 95.0%

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

    if -1 < z < 4.19999999999999962e-15

    1. Initial program 80.7%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Step-by-step derivation
      1. *-commutative80.7%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
      2. associate-*l/80.5%

        \[\leadsto \color{blue}{\frac{y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \cdot x} \]
      3. *-commutative80.5%

        \[\leadsto \color{blue}{x \cdot \frac{y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}} \]
      4. sqr-neg80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(\left(-z\right) \cdot \left(-z\right)\right)} \cdot \left(z + 1\right)} \]
      5. *-commutative80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(z + 1\right) \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)}} \]
      6. distribute-rgt1-in80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(-z\right) \cdot \left(-z\right) + z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)}} \]
      7. sqr-neg80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot z} + z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)} \]
      8. fma-def80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\mathsf{fma}\left(z, z, z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)\right)}} \]
      9. sqr-neg80.5%

        \[\leadsto x \cdot \frac{y}{\mathsf{fma}\left(z, z, z \cdot \color{blue}{\left(z \cdot z\right)}\right)} \]
      10. cube-unmult80.5%

        \[\leadsto x \cdot \frac{y}{\mathsf{fma}\left(z, z, \color{blue}{{z}^{3}}\right)} \]
    3. Simplified80.5%

      \[\leadsto \color{blue}{x \cdot \frac{y}{\mathsf{fma}\left(z, z, {z}^{3}\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-def80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot z + {z}^{3}}} \]
      2. associate-*r/80.7%

        \[\leadsto \color{blue}{\frac{x \cdot y}{z \cdot z + {z}^{3}}} \]
      3. *-commutative80.7%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{z \cdot z + {z}^{3}} \]
      4. cube-mult80.7%

        \[\leadsto \frac{y \cdot x}{z \cdot z + \color{blue}{z \cdot \left(z \cdot z\right)}} \]
      5. distribute-rgt1-in80.7%

        \[\leadsto \frac{y \cdot x}{\color{blue}{\left(z + 1\right) \cdot \left(z \cdot z\right)}} \]
      6. *-commutative80.7%

        \[\leadsto \frac{y \cdot x}{\color{blue}{\left(z \cdot z\right) \cdot \left(z + 1\right)}} \]
      7. frac-times80.5%

        \[\leadsto \color{blue}{\frac{y}{z \cdot z} \cdot \frac{x}{z + 1}} \]
      8. associate-/r*89.8%

        \[\leadsto \color{blue}{\frac{\frac{y}{z}}{z}} \cdot \frac{x}{z + 1} \]
      9. associate-*l/96.4%

        \[\leadsto \color{blue}{\frac{\frac{y}{z} \cdot \frac{x}{z + 1}}{z}} \]
    6. Applied egg-rr96.4%

      \[\leadsto \color{blue}{\frac{\frac{y}{z} \cdot \frac{x}{z + 1}}{z}} \]
    7. Taylor expanded in z around 0 85.5%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(x \cdot y\right) + \frac{x \cdot y}{z}}}{z} \]
    8. Step-by-step derivation
      1. mul-1-neg85.5%

        \[\leadsto \frac{\color{blue}{\left(-x \cdot y\right)} + \frac{x \cdot y}{z}}{z} \]
      2. distribute-lft-neg-out85.5%

        \[\leadsto \frac{\color{blue}{\left(-x\right) \cdot y} + \frac{x \cdot y}{z}}{z} \]
      3. associate-*l/91.0%

        \[\leadsto \frac{\left(-x\right) \cdot y + \color{blue}{\frac{x}{z} \cdot y}}{z} \]
      4. distribute-rgt-out94.8%

        \[\leadsto \frac{\color{blue}{y \cdot \left(\left(-x\right) + \frac{x}{z}\right)}}{z} \]
      5. +-commutative94.8%

        \[\leadsto \frac{y \cdot \color{blue}{\left(\frac{x}{z} + \left(-x\right)\right)}}{z} \]
      6. unsub-neg94.8%

        \[\leadsto \frac{y \cdot \color{blue}{\left(\frac{x}{z} - x\right)}}{z} \]
    9. Simplified94.8%

      \[\leadsto \frac{\color{blue}{y \cdot \left(\frac{x}{z} - x\right)}}{z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification94.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 4.2 \cdot 10^{-15}\right):\\ \;\;\;\;\frac{\frac{y}{z} \cdot \frac{x}{z}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot \left(\frac{x}{z} - x\right)}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 93.8% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;\frac{x}{z} \cdot \frac{y}{z \cdot z}\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-15}:\\ \;\;\;\;\frac{y \cdot \frac{x}{z}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{\frac{x}{z}}{z}\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= z -1.0)
   (* (/ x z) (/ y (* z z)))
   (if (<= z 4.2e-15) (/ (* y (/ x z)) z) (* (/ y z) (/ (/ x z) z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.0) {
		tmp = (x / z) * (y / (z * z));
	} else if (z <= 4.2e-15) {
		tmp = (y * (x / z)) / z;
	} else {
		tmp = (y / z) * ((x / z) / z);
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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 (z <= (-1.0d0)) then
        tmp = (x / z) * (y / (z * z))
    else if (z <= 4.2d-15) then
        tmp = (y * (x / z)) / z
    else
        tmp = (y / z) * ((x / z) / z)
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.0) {
		tmp = (x / z) * (y / (z * z));
	} else if (z <= 4.2e-15) {
		tmp = (y * (x / z)) / z;
	} else {
		tmp = (y / z) * ((x / z) / z);
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if z <= -1.0:
		tmp = (x / z) * (y / (z * z))
	elif z <= 4.2e-15:
		tmp = (y * (x / z)) / z
	else:
		tmp = (y / z) * ((x / z) / z)
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (z <= -1.0)
		tmp = Float64(Float64(x / z) * Float64(y / Float64(z * z)));
	elseif (z <= 4.2e-15)
		tmp = Float64(Float64(y * Float64(x / z)) / z);
	else
		tmp = Float64(Float64(y / z) * Float64(Float64(x / z) / z));
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -1.0)
		tmp = (x / z) * (y / (z * z));
	elseif (z <= 4.2e-15)
		tmp = (y * (x / z)) / z;
	else
		tmp = (y / z) * ((x / z) / z);
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[z, -1.0], N[(N[(x / z), $MachinePrecision] * N[(y / N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4.2e-15], N[(N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * N[(N[(x / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;\frac{x}{z} \cdot \frac{y}{z \cdot z}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1

    1. Initial program 92.8%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Step-by-step derivation
      1. sqr-neg92.8%

        \[\leadsto \frac{x \cdot y}{\color{blue}{\left(\left(-z\right) \cdot \left(-z\right)\right)} \cdot \left(z + 1\right)} \]
      2. *-commutative92.8%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{\left(\left(-z\right) \cdot \left(-z\right)\right) \cdot \left(z + 1\right)} \]
      3. times-frac98.1%

        \[\leadsto \color{blue}{\frac{y}{\left(-z\right) \cdot \left(-z\right)} \cdot \frac{x}{z + 1}} \]
      4. sqr-neg98.1%

        \[\leadsto \frac{y}{\color{blue}{z \cdot z}} \cdot \frac{x}{z + 1} \]
    3. Simplified98.1%

      \[\leadsto \color{blue}{\frac{y}{z \cdot z} \cdot \frac{x}{z + 1}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 96.7%

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

    if -1 < z < 4.19999999999999962e-15

    1. Initial program 80.7%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Step-by-step derivation
      1. *-commutative80.7%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
      2. associate-*l/80.5%

        \[\leadsto \color{blue}{\frac{y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \cdot x} \]
      3. *-commutative80.5%

        \[\leadsto \color{blue}{x \cdot \frac{y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}} \]
      4. sqr-neg80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(\left(-z\right) \cdot \left(-z\right)\right)} \cdot \left(z + 1\right)} \]
      5. *-commutative80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(z + 1\right) \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)}} \]
      6. distribute-rgt1-in80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(-z\right) \cdot \left(-z\right) + z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)}} \]
      7. sqr-neg80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot z} + z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)} \]
      8. fma-def80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\mathsf{fma}\left(z, z, z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)\right)}} \]
      9. sqr-neg80.5%

        \[\leadsto x \cdot \frac{y}{\mathsf{fma}\left(z, z, z \cdot \color{blue}{\left(z \cdot z\right)}\right)} \]
      10. cube-unmult80.5%

        \[\leadsto x \cdot \frac{y}{\mathsf{fma}\left(z, z, \color{blue}{{z}^{3}}\right)} \]
    3. Simplified80.5%

      \[\leadsto \color{blue}{x \cdot \frac{y}{\mathsf{fma}\left(z, z, {z}^{3}\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-def80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot z + {z}^{3}}} \]
      2. associate-*r/80.7%

        \[\leadsto \color{blue}{\frac{x \cdot y}{z \cdot z + {z}^{3}}} \]
      3. *-commutative80.7%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{z \cdot z + {z}^{3}} \]
      4. cube-mult80.7%

        \[\leadsto \frac{y \cdot x}{z \cdot z + \color{blue}{z \cdot \left(z \cdot z\right)}} \]
      5. distribute-rgt1-in80.7%

        \[\leadsto \frac{y \cdot x}{\color{blue}{\left(z + 1\right) \cdot \left(z \cdot z\right)}} \]
      6. *-commutative80.7%

        \[\leadsto \frac{y \cdot x}{\color{blue}{\left(z \cdot z\right) \cdot \left(z + 1\right)}} \]
      7. frac-times80.5%

        \[\leadsto \color{blue}{\frac{y}{z \cdot z} \cdot \frac{x}{z + 1}} \]
      8. associate-/r*89.8%

        \[\leadsto \color{blue}{\frac{\frac{y}{z}}{z}} \cdot \frac{x}{z + 1} \]
      9. associate-*l/96.4%

        \[\leadsto \color{blue}{\frac{\frac{y}{z} \cdot \frac{x}{z + 1}}{z}} \]
    6. Applied egg-rr96.4%

      \[\leadsto \color{blue}{\frac{\frac{y}{z} \cdot \frac{x}{z + 1}}{z}} \]
    7. Taylor expanded in z around 0 88.7%

      \[\leadsto \frac{\color{blue}{\frac{x \cdot y}{z}}}{z} \]
    8. Step-by-step derivation
      1. associate-*l/94.1%

        \[\leadsto \frac{\color{blue}{\frac{x}{z} \cdot y}}{z} \]
      2. *-commutative94.1%

        \[\leadsto \frac{\color{blue}{y \cdot \frac{x}{z}}}{z} \]
    9. Simplified94.1%

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

    if 4.19999999999999962e-15 < z

    1. Initial program 87.2%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative87.2%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
      2. frac-times93.9%

        \[\leadsto \color{blue}{\frac{y}{z \cdot z} \cdot \frac{x}{z + 1}} \]
      3. associate-*l/92.6%

        \[\leadsto \color{blue}{\frac{y \cdot \frac{x}{z + 1}}{z \cdot z}} \]
      4. times-frac98.4%

        \[\leadsto \color{blue}{\frac{y}{z} \cdot \frac{\frac{x}{z + 1}}{z}} \]
    4. Applied egg-rr98.4%

      \[\leadsto \color{blue}{\frac{y}{z} \cdot \frac{\frac{x}{z + 1}}{z}} \]
    5. Taylor expanded in z around inf 93.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;\frac{x}{z} \cdot \frac{y}{z \cdot z}\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-15}:\\ \;\;\;\;\frac{y \cdot \frac{x}{z}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{\frac{x}{z}}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 93.9% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;\frac{x}{z} \cdot \frac{y}{z \cdot z}\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-15}:\\ \;\;\;\;\frac{y \cdot \left(\frac{x}{z} - x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{\frac{x}{z}}{z}\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= z -1.0)
   (* (/ x z) (/ y (* z z)))
   (if (<= z 4.2e-15) (/ (* y (- (/ x z) x)) z) (* (/ y z) (/ (/ x z) z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.0) {
		tmp = (x / z) * (y / (z * z));
	} else if (z <= 4.2e-15) {
		tmp = (y * ((x / z) - x)) / z;
	} else {
		tmp = (y / z) * ((x / z) / z);
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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 (z <= (-1.0d0)) then
        tmp = (x / z) * (y / (z * z))
    else if (z <= 4.2d-15) then
        tmp = (y * ((x / z) - x)) / z
    else
        tmp = (y / z) * ((x / z) / z)
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.0) {
		tmp = (x / z) * (y / (z * z));
	} else if (z <= 4.2e-15) {
		tmp = (y * ((x / z) - x)) / z;
	} else {
		tmp = (y / z) * ((x / z) / z);
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if z <= -1.0:
		tmp = (x / z) * (y / (z * z))
	elif z <= 4.2e-15:
		tmp = (y * ((x / z) - x)) / z
	else:
		tmp = (y / z) * ((x / z) / z)
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (z <= -1.0)
		tmp = Float64(Float64(x / z) * Float64(y / Float64(z * z)));
	elseif (z <= 4.2e-15)
		tmp = Float64(Float64(y * Float64(Float64(x / z) - x)) / z);
	else
		tmp = Float64(Float64(y / z) * Float64(Float64(x / z) / z));
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -1.0)
		tmp = (x / z) * (y / (z * z));
	elseif (z <= 4.2e-15)
		tmp = (y * ((x / z) - x)) / z;
	else
		tmp = (y / z) * ((x / z) / z);
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[z, -1.0], N[(N[(x / z), $MachinePrecision] * N[(y / N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4.2e-15], N[(N[(y * N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * N[(N[(x / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;\frac{x}{z} \cdot \frac{y}{z \cdot z}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1

    1. Initial program 92.8%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Step-by-step derivation
      1. sqr-neg92.8%

        \[\leadsto \frac{x \cdot y}{\color{blue}{\left(\left(-z\right) \cdot \left(-z\right)\right)} \cdot \left(z + 1\right)} \]
      2. *-commutative92.8%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{\left(\left(-z\right) \cdot \left(-z\right)\right) \cdot \left(z + 1\right)} \]
      3. times-frac98.1%

        \[\leadsto \color{blue}{\frac{y}{\left(-z\right) \cdot \left(-z\right)} \cdot \frac{x}{z + 1}} \]
      4. sqr-neg98.1%

        \[\leadsto \frac{y}{\color{blue}{z \cdot z}} \cdot \frac{x}{z + 1} \]
    3. Simplified98.1%

      \[\leadsto \color{blue}{\frac{y}{z \cdot z} \cdot \frac{x}{z + 1}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 96.7%

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

    if -1 < z < 4.19999999999999962e-15

    1. Initial program 80.7%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Step-by-step derivation
      1. *-commutative80.7%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
      2. associate-*l/80.5%

        \[\leadsto \color{blue}{\frac{y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \cdot x} \]
      3. *-commutative80.5%

        \[\leadsto \color{blue}{x \cdot \frac{y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}} \]
      4. sqr-neg80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(\left(-z\right) \cdot \left(-z\right)\right)} \cdot \left(z + 1\right)} \]
      5. *-commutative80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(z + 1\right) \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)}} \]
      6. distribute-rgt1-in80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(-z\right) \cdot \left(-z\right) + z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)}} \]
      7. sqr-neg80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot z} + z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)} \]
      8. fma-def80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\mathsf{fma}\left(z, z, z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)\right)}} \]
      9. sqr-neg80.5%

        \[\leadsto x \cdot \frac{y}{\mathsf{fma}\left(z, z, z \cdot \color{blue}{\left(z \cdot z\right)}\right)} \]
      10. cube-unmult80.5%

        \[\leadsto x \cdot \frac{y}{\mathsf{fma}\left(z, z, \color{blue}{{z}^{3}}\right)} \]
    3. Simplified80.5%

      \[\leadsto \color{blue}{x \cdot \frac{y}{\mathsf{fma}\left(z, z, {z}^{3}\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-def80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot z + {z}^{3}}} \]
      2. associate-*r/80.7%

        \[\leadsto \color{blue}{\frac{x \cdot y}{z \cdot z + {z}^{3}}} \]
      3. *-commutative80.7%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{z \cdot z + {z}^{3}} \]
      4. cube-mult80.7%

        \[\leadsto \frac{y \cdot x}{z \cdot z + \color{blue}{z \cdot \left(z \cdot z\right)}} \]
      5. distribute-rgt1-in80.7%

        \[\leadsto \frac{y \cdot x}{\color{blue}{\left(z + 1\right) \cdot \left(z \cdot z\right)}} \]
      6. *-commutative80.7%

        \[\leadsto \frac{y \cdot x}{\color{blue}{\left(z \cdot z\right) \cdot \left(z + 1\right)}} \]
      7. frac-times80.5%

        \[\leadsto \color{blue}{\frac{y}{z \cdot z} \cdot \frac{x}{z + 1}} \]
      8. associate-/r*89.8%

        \[\leadsto \color{blue}{\frac{\frac{y}{z}}{z}} \cdot \frac{x}{z + 1} \]
      9. associate-*l/96.4%

        \[\leadsto \color{blue}{\frac{\frac{y}{z} \cdot \frac{x}{z + 1}}{z}} \]
    6. Applied egg-rr96.4%

      \[\leadsto \color{blue}{\frac{\frac{y}{z} \cdot \frac{x}{z + 1}}{z}} \]
    7. Taylor expanded in z around 0 85.5%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(x \cdot y\right) + \frac{x \cdot y}{z}}}{z} \]
    8. Step-by-step derivation
      1. mul-1-neg85.5%

        \[\leadsto \frac{\color{blue}{\left(-x \cdot y\right)} + \frac{x \cdot y}{z}}{z} \]
      2. distribute-lft-neg-out85.5%

        \[\leadsto \frac{\color{blue}{\left(-x\right) \cdot y} + \frac{x \cdot y}{z}}{z} \]
      3. associate-*l/91.0%

        \[\leadsto \frac{\left(-x\right) \cdot y + \color{blue}{\frac{x}{z} \cdot y}}{z} \]
      4. distribute-rgt-out94.8%

        \[\leadsto \frac{\color{blue}{y \cdot \left(\left(-x\right) + \frac{x}{z}\right)}}{z} \]
      5. +-commutative94.8%

        \[\leadsto \frac{y \cdot \color{blue}{\left(\frac{x}{z} + \left(-x\right)\right)}}{z} \]
      6. unsub-neg94.8%

        \[\leadsto \frac{y \cdot \color{blue}{\left(\frac{x}{z} - x\right)}}{z} \]
    9. Simplified94.8%

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

    if 4.19999999999999962e-15 < z

    1. Initial program 87.2%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative87.2%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
      2. frac-times93.9%

        \[\leadsto \color{blue}{\frac{y}{z \cdot z} \cdot \frac{x}{z + 1}} \]
      3. associate-*l/92.6%

        \[\leadsto \color{blue}{\frac{y \cdot \frac{x}{z + 1}}{z \cdot z}} \]
      4. times-frac98.4%

        \[\leadsto \color{blue}{\frac{y}{z} \cdot \frac{\frac{x}{z + 1}}{z}} \]
    4. Applied egg-rr98.4%

      \[\leadsto \color{blue}{\frac{y}{z} \cdot \frac{\frac{x}{z + 1}}{z}} \]
    5. Taylor expanded in z around inf 93.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;\frac{x}{z} \cdot \frac{y}{z \cdot z}\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-15}:\\ \;\;\;\;\frac{y \cdot \left(\frac{x}{z} - x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{\frac{x}{z}}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 94.9% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;\frac{\frac{y \cdot \frac{x}{z}}{z}}{z}\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-15}:\\ \;\;\;\;\frac{y \cdot \left(\frac{x}{z} - x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z} \cdot \frac{x}{z}}{z}\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= z -1.0)
   (/ (/ (* y (/ x z)) z) z)
   (if (<= z 4.2e-15) (/ (* y (- (/ x z) x)) z) (/ (* (/ y z) (/ x z)) z))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.0) {
		tmp = ((y * (x / z)) / z) / z;
	} else if (z <= 4.2e-15) {
		tmp = (y * ((x / z) - x)) / z;
	} else {
		tmp = ((y / z) * (x / z)) / z;
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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 (z <= (-1.0d0)) then
        tmp = ((y * (x / z)) / z) / z
    else if (z <= 4.2d-15) then
        tmp = (y * ((x / z) - x)) / z
    else
        tmp = ((y / z) * (x / z)) / z
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.0) {
		tmp = ((y * (x / z)) / z) / z;
	} else if (z <= 4.2e-15) {
		tmp = (y * ((x / z) - x)) / z;
	} else {
		tmp = ((y / z) * (x / z)) / z;
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if z <= -1.0:
		tmp = ((y * (x / z)) / z) / z
	elif z <= 4.2e-15:
		tmp = (y * ((x / z) - x)) / z
	else:
		tmp = ((y / z) * (x / z)) / z
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (z <= -1.0)
		tmp = Float64(Float64(Float64(y * Float64(x / z)) / z) / z);
	elseif (z <= 4.2e-15)
		tmp = Float64(Float64(y * Float64(Float64(x / z) - x)) / z);
	else
		tmp = Float64(Float64(Float64(y / z) * Float64(x / z)) / z);
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -1.0)
		tmp = ((y * (x / z)) / z) / z;
	elseif (z <= 4.2e-15)
		tmp = (y * ((x / z) - x)) / z;
	else
		tmp = ((y / z) * (x / z)) / z;
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[z, -1.0], N[(N[(N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 4.2e-15], N[(N[(y * N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(y / z), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;\frac{\frac{y \cdot \frac{x}{z}}{z}}{z}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1

    1. Initial program 92.8%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Step-by-step derivation
      1. *-commutative92.8%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
      2. associate-*l/98.1%

        \[\leadsto \color{blue}{\frac{y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \cdot x} \]
      3. *-commutative98.1%

        \[\leadsto \color{blue}{x \cdot \frac{y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}} \]
      4. sqr-neg98.1%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(\left(-z\right) \cdot \left(-z\right)\right)} \cdot \left(z + 1\right)} \]
      5. *-commutative98.1%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(z + 1\right) \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)}} \]
      6. distribute-rgt1-in42.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(-z\right) \cdot \left(-z\right) + z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)}} \]
      7. sqr-neg42.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot z} + z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)} \]
      8. fma-def98.2%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\mathsf{fma}\left(z, z, z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)\right)}} \]
      9. sqr-neg98.2%

        \[\leadsto x \cdot \frac{y}{\mathsf{fma}\left(z, z, z \cdot \color{blue}{\left(z \cdot z\right)}\right)} \]
      10. cube-unmult98.2%

        \[\leadsto x \cdot \frac{y}{\mathsf{fma}\left(z, z, \color{blue}{{z}^{3}}\right)} \]
    3. Simplified98.2%

      \[\leadsto \color{blue}{x \cdot \frac{y}{\mathsf{fma}\left(z, z, {z}^{3}\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-def42.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot z + {z}^{3}}} \]
      2. associate-*r/40.8%

        \[\leadsto \color{blue}{\frac{x \cdot y}{z \cdot z + {z}^{3}}} \]
      3. *-commutative40.8%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{z \cdot z + {z}^{3}} \]
      4. cube-mult40.8%

        \[\leadsto \frac{y \cdot x}{z \cdot z + \color{blue}{z \cdot \left(z \cdot z\right)}} \]
      5. distribute-rgt1-in92.8%

        \[\leadsto \frac{y \cdot x}{\color{blue}{\left(z + 1\right) \cdot \left(z \cdot z\right)}} \]
      6. *-commutative92.8%

        \[\leadsto \frac{y \cdot x}{\color{blue}{\left(z \cdot z\right) \cdot \left(z + 1\right)}} \]
      7. frac-times98.1%

        \[\leadsto \color{blue}{\frac{y}{z \cdot z} \cdot \frac{x}{z + 1}} \]
      8. associate-*l/96.4%

        \[\leadsto \color{blue}{\frac{y \cdot \frac{x}{z + 1}}{z \cdot z}} \]
      9. associate-/r*98.2%

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

      \[\leadsto \color{blue}{\frac{\frac{y \cdot \frac{x}{z + 1}}{z}}{z}} \]
    7. Taylor expanded in z around inf 96.8%

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

    if -1 < z < 4.19999999999999962e-15

    1. Initial program 80.7%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Step-by-step derivation
      1. *-commutative80.7%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
      2. associate-*l/80.5%

        \[\leadsto \color{blue}{\frac{y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \cdot x} \]
      3. *-commutative80.5%

        \[\leadsto \color{blue}{x \cdot \frac{y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}} \]
      4. sqr-neg80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(\left(-z\right) \cdot \left(-z\right)\right)} \cdot \left(z + 1\right)} \]
      5. *-commutative80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(z + 1\right) \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)}} \]
      6. distribute-rgt1-in80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(-z\right) \cdot \left(-z\right) + z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)}} \]
      7. sqr-neg80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot z} + z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)} \]
      8. fma-def80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\mathsf{fma}\left(z, z, z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)\right)}} \]
      9. sqr-neg80.5%

        \[\leadsto x \cdot \frac{y}{\mathsf{fma}\left(z, z, z \cdot \color{blue}{\left(z \cdot z\right)}\right)} \]
      10. cube-unmult80.5%

        \[\leadsto x \cdot \frac{y}{\mathsf{fma}\left(z, z, \color{blue}{{z}^{3}}\right)} \]
    3. Simplified80.5%

      \[\leadsto \color{blue}{x \cdot \frac{y}{\mathsf{fma}\left(z, z, {z}^{3}\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-def80.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot z + {z}^{3}}} \]
      2. associate-*r/80.7%

        \[\leadsto \color{blue}{\frac{x \cdot y}{z \cdot z + {z}^{3}}} \]
      3. *-commutative80.7%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{z \cdot z + {z}^{3}} \]
      4. cube-mult80.7%

        \[\leadsto \frac{y \cdot x}{z \cdot z + \color{blue}{z \cdot \left(z \cdot z\right)}} \]
      5. distribute-rgt1-in80.7%

        \[\leadsto \frac{y \cdot x}{\color{blue}{\left(z + 1\right) \cdot \left(z \cdot z\right)}} \]
      6. *-commutative80.7%

        \[\leadsto \frac{y \cdot x}{\color{blue}{\left(z \cdot z\right) \cdot \left(z + 1\right)}} \]
      7. frac-times80.5%

        \[\leadsto \color{blue}{\frac{y}{z \cdot z} \cdot \frac{x}{z + 1}} \]
      8. associate-/r*89.8%

        \[\leadsto \color{blue}{\frac{\frac{y}{z}}{z}} \cdot \frac{x}{z + 1} \]
      9. associate-*l/96.4%

        \[\leadsto \color{blue}{\frac{\frac{y}{z} \cdot \frac{x}{z + 1}}{z}} \]
    6. Applied egg-rr96.4%

      \[\leadsto \color{blue}{\frac{\frac{y}{z} \cdot \frac{x}{z + 1}}{z}} \]
    7. Taylor expanded in z around 0 85.5%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(x \cdot y\right) + \frac{x \cdot y}{z}}}{z} \]
    8. Step-by-step derivation
      1. mul-1-neg85.5%

        \[\leadsto \frac{\color{blue}{\left(-x \cdot y\right)} + \frac{x \cdot y}{z}}{z} \]
      2. distribute-lft-neg-out85.5%

        \[\leadsto \frac{\color{blue}{\left(-x\right) \cdot y} + \frac{x \cdot y}{z}}{z} \]
      3. associate-*l/91.0%

        \[\leadsto \frac{\left(-x\right) \cdot y + \color{blue}{\frac{x}{z} \cdot y}}{z} \]
      4. distribute-rgt-out94.8%

        \[\leadsto \frac{\color{blue}{y \cdot \left(\left(-x\right) + \frac{x}{z}\right)}}{z} \]
      5. +-commutative94.8%

        \[\leadsto \frac{y \cdot \color{blue}{\left(\frac{x}{z} + \left(-x\right)\right)}}{z} \]
      6. unsub-neg94.8%

        \[\leadsto \frac{y \cdot \color{blue}{\left(\frac{x}{z} - x\right)}}{z} \]
    9. Simplified94.8%

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

    if 4.19999999999999962e-15 < z

    1. Initial program 87.2%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Step-by-step derivation
      1. *-commutative87.2%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
      2. associate-*l/93.4%

        \[\leadsto \color{blue}{\frac{y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \cdot x} \]
      3. *-commutative93.4%

        \[\leadsto \color{blue}{x \cdot \frac{y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}} \]
      4. sqr-neg93.4%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(\left(-z\right) \cdot \left(-z\right)\right)} \cdot \left(z + 1\right)} \]
      5. *-commutative93.4%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(z + 1\right) \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)}} \]
      6. distribute-rgt1-in93.4%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(-z\right) \cdot \left(-z\right) + z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)}} \]
      7. sqr-neg93.4%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot z} + z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)} \]
      8. fma-def93.4%

        \[\leadsto x \cdot \frac{y}{\color{blue}{\mathsf{fma}\left(z, z, z \cdot \left(\left(-z\right) \cdot \left(-z\right)\right)\right)}} \]
      9. sqr-neg93.4%

        \[\leadsto x \cdot \frac{y}{\mathsf{fma}\left(z, z, z \cdot \color{blue}{\left(z \cdot z\right)}\right)} \]
      10. cube-unmult93.4%

        \[\leadsto x \cdot \frac{y}{\mathsf{fma}\left(z, z, \color{blue}{{z}^{3}}\right)} \]
    3. Simplified93.4%

      \[\leadsto \color{blue}{x \cdot \frac{y}{\mathsf{fma}\left(z, z, {z}^{3}\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-def93.4%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot z + {z}^{3}}} \]
      2. associate-*r/87.2%

        \[\leadsto \color{blue}{\frac{x \cdot y}{z \cdot z + {z}^{3}}} \]
      3. *-commutative87.2%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{z \cdot z + {z}^{3}} \]
      4. cube-mult87.2%

        \[\leadsto \frac{y \cdot x}{z \cdot z + \color{blue}{z \cdot \left(z \cdot z\right)}} \]
      5. distribute-rgt1-in87.2%

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

        \[\leadsto \frac{y \cdot x}{\color{blue}{\left(z \cdot z\right) \cdot \left(z + 1\right)}} \]
      7. frac-times93.9%

        \[\leadsto \color{blue}{\frac{y}{z \cdot z} \cdot \frac{x}{z + 1}} \]
      8. associate-/r*98.5%

        \[\leadsto \color{blue}{\frac{\frac{y}{z}}{z}} \cdot \frac{x}{z + 1} \]
      9. associate-*l/98.5%

        \[\leadsto \color{blue}{\frac{\frac{y}{z} \cdot \frac{x}{z + 1}}{z}} \]
    6. Applied egg-rr98.5%

      \[\leadsto \color{blue}{\frac{\frac{y}{z} \cdot \frac{x}{z + 1}}{z}} \]
    7. Taylor expanded in z around inf 93.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;\frac{\frac{y \cdot \frac{x}{z}}{z}}{z}\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-15}:\\ \;\;\;\;\frac{y \cdot \left(\frac{x}{z} - x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z} \cdot \frac{x}{z}}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 75.9% accurate, 0.9× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 1.4 \cdot 10^{-138}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{z \cdot z}\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= x 1.4e-138) (* (/ y z) (/ x z)) (* x (/ y (* z z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (x <= 1.4e-138) {
		tmp = (y / z) * (x / z);
	} else {
		tmp = x * (y / (z * z));
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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 <= 1.4d-138) then
        tmp = (y / z) * (x / z)
    else
        tmp = x * (y / (z * z))
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= 1.4e-138) {
		tmp = (y / z) * (x / z);
	} else {
		tmp = x * (y / (z * z));
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if x <= 1.4e-138:
		tmp = (y / z) * (x / z)
	else:
		tmp = x * (y / (z * z))
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (x <= 1.4e-138)
		tmp = Float64(Float64(y / z) * Float64(x / z));
	else
		tmp = Float64(x * Float64(y / Float64(z * z)));
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= 1.4e-138)
		tmp = (y / z) * (x / z);
	else
		tmp = x * (y / (z * z));
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[x, 1.4e-138], N[(N[(y / z), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.4 \cdot 10^{-138}:\\
\;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.4e-138

    1. Initial program 82.8%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative82.8%

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

        \[\leadsto \color{blue}{\frac{y}{z \cdot z} \cdot \frac{x}{z + 1}} \]
      3. associate-*l/84.5%

        \[\leadsto \color{blue}{\frac{y \cdot \frac{x}{z + 1}}{z \cdot z}} \]
      4. times-frac97.5%

        \[\leadsto \color{blue}{\frac{y}{z} \cdot \frac{\frac{x}{z + 1}}{z}} \]
    4. Applied egg-rr97.5%

      \[\leadsto \color{blue}{\frac{y}{z} \cdot \frac{\frac{x}{z + 1}}{z}} \]
    5. Taylor expanded in z around 0 81.3%

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

    if 1.4e-138 < x

    1. Initial program 89.1%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Step-by-step derivation
      1. sqr-neg89.1%

        \[\leadsto \frac{x \cdot y}{\color{blue}{\left(\left(-z\right) \cdot \left(-z\right)\right)} \cdot \left(z + 1\right)} \]
      2. *-commutative89.1%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{\left(\left(-z\right) \cdot \left(-z\right)\right) \cdot \left(z + 1\right)} \]
      3. times-frac92.6%

        \[\leadsto \color{blue}{\frac{y}{\left(-z\right) \cdot \left(-z\right)} \cdot \frac{x}{z + 1}} \]
      4. sqr-neg92.6%

        \[\leadsto \frac{y}{\color{blue}{z \cdot z}} \cdot \frac{x}{z + 1} \]
    3. Simplified92.6%

      \[\leadsto \color{blue}{\frac{y}{z \cdot z} \cdot \frac{x}{z + 1}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 79.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.4 \cdot 10^{-138}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{z \cdot z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 78.9% accurate, 0.9× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 10^{-40}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z \cdot \frac{z}{x}}\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= y 1e-40) (* (/ y z) (/ x z)) (/ y (* z (/ z x)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (y <= 1e-40) {
		tmp = (y / z) * (x / z);
	} else {
		tmp = y / (z * (z / x));
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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 (y <= 1d-40) then
        tmp = (y / z) * (x / z)
    else
        tmp = y / (z * (z / x))
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 1e-40) {
		tmp = (y / z) * (x / z);
	} else {
		tmp = y / (z * (z / x));
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if y <= 1e-40:
		tmp = (y / z) * (x / z)
	else:
		tmp = y / (z * (z / x))
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (y <= 1e-40)
		tmp = Float64(Float64(y / z) * Float64(x / z));
	else
		tmp = Float64(y / Float64(z * Float64(z / x)));
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 1e-40)
		tmp = (y / z) * (x / z);
	else
		tmp = y / (z * (z / x));
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[y, 1e-40], N[(N[(y / z), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y / N[(z * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 10^{-40}:\\
\;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 9.9999999999999993e-41

    1. Initial program 85.5%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative85.5%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
      2. frac-times87.3%

        \[\leadsto \color{blue}{\frac{y}{z \cdot z} \cdot \frac{x}{z + 1}} \]
      3. associate-*l/86.5%

        \[\leadsto \color{blue}{\frac{y \cdot \frac{x}{z + 1}}{z \cdot z}} \]
      4. times-frac97.4%

        \[\leadsto \color{blue}{\frac{y}{z} \cdot \frac{\frac{x}{z + 1}}{z}} \]
    4. Applied egg-rr97.4%

      \[\leadsto \color{blue}{\frac{y}{z} \cdot \frac{\frac{x}{z + 1}}{z}} \]
    5. Taylor expanded in z around 0 84.2%

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

    if 9.9999999999999993e-41 < y

    1. Initial program 83.5%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative83.5%

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

        \[\leadsto \color{blue}{\frac{y}{z \cdot z} \cdot \frac{x}{z + 1}} \]
      3. associate-*l/89.8%

        \[\leadsto \color{blue}{\frac{y \cdot \frac{x}{z + 1}}{z \cdot z}} \]
      4. times-frac96.7%

        \[\leadsto \color{blue}{\frac{y}{z} \cdot \frac{\frac{x}{z + 1}}{z}} \]
    4. Applied egg-rr96.7%

      \[\leadsto \color{blue}{\frac{y}{z} \cdot \frac{\frac{x}{z + 1}}{z}} \]
    5. Taylor expanded in z around 0 59.9%

      \[\leadsto \frac{y}{z} \cdot \color{blue}{\frac{x}{z}} \]
    6. Step-by-step derivation
      1. associate-/r/66.5%

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{\frac{x}{z}}}} \]
      2. div-inv66.5%

        \[\leadsto \frac{y}{\color{blue}{z \cdot \frac{1}{\frac{x}{z}}}} \]
      3. clear-num66.5%

        \[\leadsto \frac{y}{z \cdot \color{blue}{\frac{z}{x}}} \]
    7. Applied egg-rr66.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 10^{-40}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z \cdot \frac{z}{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 75.3% accurate, 1.6× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \frac{y}{z} \cdot \frac{x}{z} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z) :precision binary64 (* (/ y z) (/ x z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
	return (y / z) * (x / z);
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (y / z) * (x / z)
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	return (y / z) * (x / z);
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	return (y / z) * (x / z)
x, y, z = sort([x, y, z])
function code(x, y, z)
	return Float64(Float64(y / z) * Float64(x / z))
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
	tmp = (y / z) * (x / z);
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := N[(N[(y / z), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\frac{y}{z} \cdot \frac{x}{z}
\end{array}
Derivation
  1. Initial program 85.0%

    \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. *-commutative85.0%

      \[\leadsto \frac{\color{blue}{y \cdot x}}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. frac-times87.9%

      \[\leadsto \color{blue}{\frac{y}{z \cdot z} \cdot \frac{x}{z + 1}} \]
    3. associate-*l/87.3%

      \[\leadsto \color{blue}{\frac{y \cdot \frac{x}{z + 1}}{z \cdot z}} \]
    4. times-frac97.2%

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

    \[\leadsto \color{blue}{\frac{y}{z} \cdot \frac{\frac{x}{z + 1}}{z}} \]
  5. Taylor expanded in z around 0 78.5%

    \[\leadsto \frac{y}{z} \cdot \color{blue}{\frac{x}{z}} \]
  6. Final simplification78.5%

    \[\leadsto \frac{y}{z} \cdot \frac{x}{z} \]
  7. Add Preprocessing

Developer target: 95.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \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} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (< z 249.6182814532307)
   (/ (* y (/ x z)) (+ z (* z z)))
   (/ (* (/ (/ y z) (+ 1.0 z)) x) z)))
double code(double x, double y, double z) {
	double tmp;
	if (z < 249.6182814532307) {
		tmp = (y * (x / z)) / (z + (z * z));
	} else {
		tmp = (((y / z) / (1.0 + z)) * x) / 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
    real(8) :: tmp
    if (z < 249.6182814532307d0) then
        tmp = (y * (x / z)) / (z + (z * z))
    else
        tmp = (((y / z) / (1.0d0 + z)) * x) / z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z < 249.6182814532307) {
		tmp = (y * (x / z)) / (z + (z * z));
	} else {
		tmp = (((y / z) / (1.0 + z)) * x) / z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z < 249.6182814532307:
		tmp = (y * (x / z)) / (z + (z * z))
	else:
		tmp = (((y / z) / (1.0 + z)) * x) / z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z < 249.6182814532307)
		tmp = Float64(Float64(y * Float64(x / z)) / Float64(z + Float64(z * z)));
	else
		tmp = Float64(Float64(Float64(Float64(y / z) / Float64(1.0 + z)) * x) / z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z < 249.6182814532307)
		tmp = (y * (x / z)) / (z + (z * z));
	else
		tmp = (((y / z) / (1.0 + z)) * x) / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Less[z, 249.6182814532307], N[(N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision] / N[(z + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(y / z), $MachinePrecision] / N[(1.0 + z), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}

\\
\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}
\end{array}

Reproduce

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