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

Percentage Accurate: 83.1% → 97.1%
Time: 10.8s
Alternatives: 15
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 15 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.1% 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: 97.1% accurate, 0.5× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\ \\ y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;\left(z + 1\right) \cdot \left(z \cdot z\right) \leq 4 \cdot 10^{+75}:\\ \;\;\;\;\frac{y\_m}{z + 1} \cdot \frac{\frac{x\_m}{z}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{x\_m}{z}}{\frac{z}{y\_m}}}{z}\\ \end{array}\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
 :precision binary64
 (*
  y_s
  (*
   x_s
   (if (<= (* (+ z 1.0) (* z z)) 4e+75)
     (* (/ y_m (+ z 1.0)) (/ (/ x_m z) z))
     (/ (/ (/ x_m z) (/ z y_m)) z)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
	double tmp;
	if (((z + 1.0) * (z * z)) <= 4e+75) {
		tmp = (y_m / (z + 1.0)) * ((x_m / z) / z);
	} else {
		tmp = ((x_m / z) / (z / y_m)) / z;
	}
	return y_s * (x_s * tmp);
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (((z + 1.0d0) * (z * z)) <= 4d+75) then
        tmp = (y_m / (z + 1.0d0)) * ((x_m / z) / z)
    else
        tmp = ((x_m / z) / (z / y_m)) / z
    end if
    code = y_s * (x_s * tmp)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
	double tmp;
	if (((z + 1.0) * (z * z)) <= 4e+75) {
		tmp = (y_m / (z + 1.0)) * ((x_m / z) / z);
	} else {
		tmp = ((x_m / z) / (z / y_m)) / z;
	}
	return y_s * (x_s * tmp);
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x_m, y_m, z] = sort([x_m, y_m, z])
def code(y_s, x_s, x_m, y_m, z):
	tmp = 0
	if ((z + 1.0) * (z * z)) <= 4e+75:
		tmp = (y_m / (z + 1.0)) * ((x_m / z) / z)
	else:
		tmp = ((x_m / z) / (z / y_m)) / z
	return y_s * (x_s * tmp)
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x_m, y_m, z = sort([x_m, y_m, z])
function code(y_s, x_s, x_m, y_m, z)
	tmp = 0.0
	if (Float64(Float64(z + 1.0) * Float64(z * z)) <= 4e+75)
		tmp = Float64(Float64(y_m / Float64(z + 1.0)) * Float64(Float64(x_m / z) / z));
	else
		tmp = Float64(Float64(Float64(x_m / z) / Float64(z / y_m)) / z);
	end
	return Float64(y_s * Float64(x_s * tmp))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z)
	tmp = 0.0;
	if (((z + 1.0) * (z * z)) <= 4e+75)
		tmp = (y_m / (z + 1.0)) * ((x_m / z) / z);
	else
		tmp = ((x_m / z) / (z / y_m)) / z;
	end
	tmp_2 = y_s * (x_s * tmp);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[LessEqual[N[(N[(z + 1.0), $MachinePrecision] * N[(z * z), $MachinePrecision]), $MachinePrecision], 4e+75], N[(N[(y$95$m / N[(z + 1.0), $MachinePrecision]), $MachinePrecision] * N[(N[(x$95$m / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$95$m / z), $MachinePrecision] / N[(z / y$95$m), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;\left(z + 1\right) \cdot \left(z \cdot z\right) \leq 4 \cdot 10^{+75}:\\
\;\;\;\;\frac{y\_m}{z + 1} \cdot \frac{\frac{x\_m}{z}}{z}\\

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


\end{array}\right)
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64))) < 3.99999999999999971e75

    1. Initial program 77.8%

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

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \frac{\frac{x}{z \cdot z}}{z + 1}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. associate-*r/85.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{x}{z} \cdot \frac{y}{z + 1}}{z}} \]
    7. Step-by-step derivation
      1. *-commutative96.4%

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

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

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

    if 3.99999999999999971e75 < (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64)))

    1. Initial program 80.8%

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

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \frac{\frac{x}{z \cdot z}}{z + 1}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. associate-*r/88.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{x}{z} \cdot \frac{y}{z + 1}}{z}} \]
    7. Step-by-step derivation
      1. clear-num99.8%

        \[\leadsto \frac{\frac{x}{z} \cdot \color{blue}{\frac{1}{\frac{z + 1}{y}}}}{z} \]
      2. un-div-inv99.9%

        \[\leadsto \frac{\color{blue}{\frac{\frac{x}{z}}{\frac{z + 1}{y}}}}{z} \]
    8. Applied egg-rr99.9%

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

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

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

Alternative 2: 47.0% accurate, 0.5× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\ \\ y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;\frac{x\_m}{z} \cdot y\_m\\ \mathbf{elif}\;z \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{y\_m}{z} \cdot \left(-x\_m\right)\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{-142}:\\ \;\;\;\;x\_m \cdot \frac{y\_m}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y\_m}{\frac{z}{x\_m}}\\ \end{array}\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
 :precision binary64
 (*
  y_s
  (*
   x_s
   (if (<= z -1.0)
     (* (/ x_m z) y_m)
     (if (<= z -5e-310)
       (* (/ y_m z) (- x_m))
       (if (<= z 3.2e-142) (* x_m (/ y_m z)) (/ y_m (/ z x_m))))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
	double tmp;
	if (z <= -1.0) {
		tmp = (x_m / z) * y_m;
	} else if (z <= -5e-310) {
		tmp = (y_m / z) * -x_m;
	} else if (z <= 3.2e-142) {
		tmp = x_m * (y_m / z);
	} else {
		tmp = y_m / (z / x_m);
	}
	return y_s * (x_s * tmp);
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-1.0d0)) then
        tmp = (x_m / z) * y_m
    else if (z <= (-5d-310)) then
        tmp = (y_m / z) * -x_m
    else if (z <= 3.2d-142) then
        tmp = x_m * (y_m / z)
    else
        tmp = y_m / (z / x_m)
    end if
    code = y_s * (x_s * tmp)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
	double tmp;
	if (z <= -1.0) {
		tmp = (x_m / z) * y_m;
	} else if (z <= -5e-310) {
		tmp = (y_m / z) * -x_m;
	} else if (z <= 3.2e-142) {
		tmp = x_m * (y_m / z);
	} else {
		tmp = y_m / (z / x_m);
	}
	return y_s * (x_s * tmp);
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x_m, y_m, z] = sort([x_m, y_m, z])
def code(y_s, x_s, x_m, y_m, z):
	tmp = 0
	if z <= -1.0:
		tmp = (x_m / z) * y_m
	elif z <= -5e-310:
		tmp = (y_m / z) * -x_m
	elif z <= 3.2e-142:
		tmp = x_m * (y_m / z)
	else:
		tmp = y_m / (z / x_m)
	return y_s * (x_s * tmp)
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x_m, y_m, z = sort([x_m, y_m, z])
function code(y_s, x_s, x_m, y_m, z)
	tmp = 0.0
	if (z <= -1.0)
		tmp = Float64(Float64(x_m / z) * y_m);
	elseif (z <= -5e-310)
		tmp = Float64(Float64(y_m / z) * Float64(-x_m));
	elseif (z <= 3.2e-142)
		tmp = Float64(x_m * Float64(y_m / z));
	else
		tmp = Float64(y_m / Float64(z / x_m));
	end
	return Float64(y_s * Float64(x_s * tmp))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z)
	tmp = 0.0;
	if (z <= -1.0)
		tmp = (x_m / z) * y_m;
	elseif (z <= -5e-310)
		tmp = (y_m / z) * -x_m;
	elseif (z <= 3.2e-142)
		tmp = x_m * (y_m / z);
	else
		tmp = y_m / (z / x_m);
	end
	tmp_2 = y_s * (x_s * tmp);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[LessEqual[z, -1.0], N[(N[(x$95$m / z), $MachinePrecision] * y$95$m), $MachinePrecision], If[LessEqual[z, -5e-310], N[(N[(y$95$m / z), $MachinePrecision] * (-x$95$m)), $MachinePrecision], If[LessEqual[z, 3.2e-142], N[(x$95$m * N[(y$95$m / z), $MachinePrecision]), $MachinePrecision], N[(y$95$m / N[(z / x$95$m), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;\frac{x\_m}{z} \cdot y\_m\\

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

\mathbf{elif}\;z \leq 3.2 \cdot 10^{-142}:\\
\;\;\;\;x\_m \cdot \frac{y\_m}{z}\\

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


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

    1. Initial program 79.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{y}{z \cdot z} \cdot \color{blue}{\left(x - x \cdot z\right)} \]
    8. Taylor expanded in z around inf 37.4%

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot y}{z}} \]
    9. Step-by-step derivation
      1. mul-1-neg37.4%

        \[\leadsto \color{blue}{-\frac{x \cdot y}{z}} \]
      2. associate-*l/41.7%

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

        \[\leadsto -\color{blue}{y \cdot \frac{x}{z}} \]
      4. distribute-rgt-neg-in41.7%

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

        \[\leadsto y \cdot \color{blue}{\frac{x}{-z}} \]
    10. Simplified41.7%

      \[\leadsto \color{blue}{y \cdot \frac{x}{-z}} \]
    11. Step-by-step derivation
      1. add-sqr-sqrt29.1%

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

        \[\leadsto y \cdot \color{blue}{\sqrt{\frac{x}{-z} \cdot \frac{x}{-z}}} \]
      3. distribute-frac-neg256.1%

        \[\leadsto y \cdot \sqrt{\color{blue}{\left(-\frac{x}{z}\right)} \cdot \frac{x}{-z}} \]
      4. distribute-frac-neg256.1%

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

        \[\leadsto y \cdot \sqrt{\color{blue}{\frac{x}{z} \cdot \frac{x}{z}}} \]
      6. sqrt-unprod35.4%

        \[\leadsto y \cdot \color{blue}{\left(\sqrt{\frac{x}{z}} \cdot \sqrt{\frac{x}{z}}\right)} \]
      7. add-sqr-sqrt44.3%

        \[\leadsto y \cdot \color{blue}{\frac{x}{z}} \]
      8. *-un-lft-identity44.3%

        \[\leadsto y \cdot \color{blue}{\left(1 \cdot \frac{x}{z}\right)} \]
    12. Applied egg-rr44.3%

      \[\leadsto y \cdot \color{blue}{\left(1 \cdot \frac{x}{z}\right)} \]
    13. Step-by-step derivation
      1. *-lft-identity44.3%

        \[\leadsto y \cdot \color{blue}{\frac{x}{z}} \]
    14. Simplified44.3%

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

    if -1 < z < -4.999999999999985e-310

    1. Initial program 73.5%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{y}{z \cdot z} \cdot \color{blue}{\left(x - x \cdot z\right)} \]
    8. Taylor expanded in z around inf 44.5%

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot y}{z}} \]
    9. Step-by-step derivation
      1. mul-1-neg44.5%

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

        \[\leadsto -\color{blue}{x \cdot \frac{y}{z}} \]
      3. distribute-lft-neg-out47.8%

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

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

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

    if -4.999999999999985e-310 < z < 3.1999999999999998e-142

    1. Initial program 69.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{y}{z \cdot z} \cdot \color{blue}{\left(x - x \cdot z\right)} \]
    8. Taylor expanded in z around inf 0.6%

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot y}{z}} \]
    9. Step-by-step derivation
      1. mul-1-neg0.6%

        \[\leadsto \color{blue}{-\frac{x \cdot y}{z}} \]
      2. associate-*l/0.5%

        \[\leadsto -\color{blue}{\frac{x}{z} \cdot y} \]
      3. *-commutative0.5%

        \[\leadsto -\color{blue}{y \cdot \frac{x}{z}} \]
      4. distribute-rgt-neg-in0.5%

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

        \[\leadsto y \cdot \color{blue}{\frac{x}{-z}} \]
    10. Simplified0.5%

      \[\leadsto \color{blue}{y \cdot \frac{x}{-z}} \]
    11. Step-by-step derivation
      1. distribute-frac-neg20.5%

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

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

        \[\leadsto \color{blue}{\frac{y \cdot \left(-x\right)}{z}} \]
    12. Applied egg-rr0.6%

      \[\leadsto \color{blue}{\frac{y \cdot \left(-x\right)}{z}} \]
    13. Step-by-step derivation
      1. add-sqr-sqrt0.6%

        \[\leadsto \frac{y \cdot \left(-x\right)}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}} \]
      2. times-frac0.5%

        \[\leadsto \color{blue}{\frac{y}{\sqrt{z}} \cdot \frac{-x}{\sqrt{z}}} \]
      3. add-sqr-sqrt0.4%

        \[\leadsto \frac{y}{\sqrt{z}} \cdot \frac{\color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{\sqrt{z}} \]
      4. sqrt-unprod22.0%

        \[\leadsto \frac{y}{\sqrt{z}} \cdot \frac{\color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}{\sqrt{z}} \]
      5. sqr-neg22.0%

        \[\leadsto \frac{y}{\sqrt{z}} \cdot \frac{\sqrt{\color{blue}{x \cdot x}}}{\sqrt{z}} \]
      6. sqrt-unprod19.6%

        \[\leadsto \frac{y}{\sqrt{z}} \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{\sqrt{z}} \]
      7. add-sqr-sqrt32.9%

        \[\leadsto \frac{y}{\sqrt{z}} \cdot \frac{\color{blue}{x}}{\sqrt{z}} \]
      8. times-frac22.3%

        \[\leadsto \color{blue}{\frac{y \cdot x}{\sqrt{z} \cdot \sqrt{z}}} \]
      9. add-sqr-sqrt22.3%

        \[\leadsto \frac{y \cdot x}{\color{blue}{z}} \]
      10. clear-num22.3%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{z}{y}}{x}}} \]
      12. associate-/r/37.3%

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

        \[\leadsto \color{blue}{\frac{y}{z}} \cdot x \]
    14. Applied egg-rr37.3%

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

    if 3.1999999999999998e-142 < z

    1. Initial program 85.5%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. 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. sqr-neg85.5%

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

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

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

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

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

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

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

      \[\leadsto \frac{y}{z \cdot z} \cdot \color{blue}{\left(x - x \cdot z\right)} \]
    8. Taylor expanded in z around inf 19.0%

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot y}{z}} \]
    9. Step-by-step derivation
      1. mul-1-neg19.0%

        \[\leadsto \color{blue}{-\frac{x \cdot y}{z}} \]
      2. associate-*l/20.2%

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

        \[\leadsto -\color{blue}{y \cdot \frac{x}{z}} \]
      4. distribute-rgt-neg-in20.2%

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

        \[\leadsto y \cdot \color{blue}{\frac{x}{-z}} \]
    10. Simplified20.2%

      \[\leadsto \color{blue}{y \cdot \frac{x}{-z}} \]
    11. Step-by-step derivation
      1. add-sqr-sqrt18.0%

        \[\leadsto y \cdot \color{blue}{\left(\sqrt{\frac{x}{-z}} \cdot \sqrt{\frac{x}{-z}}\right)} \]
      2. sqrt-unprod37.2%

        \[\leadsto y \cdot \color{blue}{\sqrt{\frac{x}{-z} \cdot \frac{x}{-z}}} \]
      3. distribute-frac-neg237.2%

        \[\leadsto y \cdot \sqrt{\color{blue}{\left(-\frac{x}{z}\right)} \cdot \frac{x}{-z}} \]
      4. distribute-frac-neg237.2%

        \[\leadsto y \cdot \sqrt{\left(-\frac{x}{z}\right) \cdot \color{blue}{\left(-\frac{x}{z}\right)}} \]
      5. sqr-neg37.2%

        \[\leadsto y \cdot \sqrt{\color{blue}{\frac{x}{z} \cdot \frac{x}{z}}} \]
      6. sqrt-unprod24.2%

        \[\leadsto y \cdot \color{blue}{\left(\sqrt{\frac{x}{z}} \cdot \sqrt{\frac{x}{z}}\right)} \]
      7. add-sqr-sqrt33.7%

        \[\leadsto y \cdot \color{blue}{\frac{x}{z}} \]
      8. clear-num33.7%

        \[\leadsto y \cdot \color{blue}{\frac{1}{\frac{z}{x}}} \]
      9. un-div-inv33.7%

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}} \]
    12. Applied egg-rr33.7%

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

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

Alternative 3: 96.4% accurate, 0.6× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\ \\ y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\ \;\;\;\;\frac{\frac{x\_m}{z} \cdot \frac{y\_m}{z}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y\_m}{z \cdot \frac{z}{x\_m}}\\ \end{array}\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
 :precision binary64
 (*
  y_s
  (*
   x_s
   (if (or (<= z -1.0) (not (<= z 1.0)))
     (/ (* (/ x_m z) (/ y_m z)) z)
     (/ y_m (* z (/ z x_m)))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
	double tmp;
	if ((z <= -1.0) || !(z <= 1.0)) {
		tmp = ((x_m / z) * (y_m / z)) / z;
	} else {
		tmp = y_m / (z * (z / x_m));
	}
	return y_s * (x_s * tmp);
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((z <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
        tmp = ((x_m / z) * (y_m / z)) / z
    else
        tmp = y_m / (z * (z / x_m))
    end if
    code = y_s * (x_s * tmp)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
	double tmp;
	if ((z <= -1.0) || !(z <= 1.0)) {
		tmp = ((x_m / z) * (y_m / z)) / z;
	} else {
		tmp = y_m / (z * (z / x_m));
	}
	return y_s * (x_s * tmp);
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x_m, y_m, z] = sort([x_m, y_m, z])
def code(y_s, x_s, x_m, y_m, z):
	tmp = 0
	if (z <= -1.0) or not (z <= 1.0):
		tmp = ((x_m / z) * (y_m / z)) / z
	else:
		tmp = y_m / (z * (z / x_m))
	return y_s * (x_s * tmp)
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x_m, y_m, z = sort([x_m, y_m, z])
function code(y_s, x_s, x_m, y_m, z)
	tmp = 0.0
	if ((z <= -1.0) || !(z <= 1.0))
		tmp = Float64(Float64(Float64(x_m / z) * Float64(y_m / z)) / z);
	else
		tmp = Float64(y_m / Float64(z * Float64(z / x_m)));
	end
	return Float64(y_s * Float64(x_s * tmp))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z)
	tmp = 0.0;
	if ((z <= -1.0) || ~((z <= 1.0)))
		tmp = ((x_m / z) * (y_m / z)) / z;
	else
		tmp = y_m / (z * (z / x_m));
	end
	tmp_2 = y_s * (x_s * tmp);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(N[(N[(x$95$m / z), $MachinePrecision] * N[(y$95$m / z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(y$95$m / N[(z * N[(z / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;\frac{\frac{x\_m}{z} \cdot \frac{y\_m}{z}}{z}\\

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


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

    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*84.8%

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \frac{\frac{x}{z \cdot z}}{z + 1}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. associate-*r/91.6%

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

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

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

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

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

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

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

    if -1 < z < 1

    1. Initial program 76.3%

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

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \frac{\frac{x}{z \cdot z}}{z + 1}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. associate-*r/80.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{x}{z} \cdot \frac{y}{z + 1}}{z}} \]
    7. Step-by-step derivation
      1. *-commutative95.4%

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

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

      \[\leadsto \color{blue}{\frac{y}{z + 1} \cdot \frac{\frac{x}{z}}{z}} \]
    9. Step-by-step derivation
      1. clear-num89.1%

        \[\leadsto \frac{y}{z + 1} \cdot \color{blue}{\frac{1}{\frac{z}{\frac{x}{z}}}} \]
      2. un-div-inv90.9%

        \[\leadsto \color{blue}{\frac{\frac{y}{z + 1}}{\frac{z}{\frac{x}{z}}}} \]
      3. div-inv90.9%

        \[\leadsto \frac{\frac{y}{z + 1}}{\color{blue}{z \cdot \frac{1}{\frac{x}{z}}}} \]
      4. clear-num90.9%

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

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

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

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

Alternative 4: 94.4% accurate, 0.6× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\ \\ y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\ \;\;\;\;\frac{x\_m}{z} \cdot \frac{y\_m}{z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y\_m}{z \cdot \frac{z}{x\_m}}\\ \end{array}\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
 :precision binary64
 (*
  y_s
  (*
   x_s
   (if (or (<= z -1.0) (not (<= z 1.0)))
     (* (/ x_m z) (/ y_m (* z z)))
     (/ y_m (* z (/ z x_m)))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
	double tmp;
	if ((z <= -1.0) || !(z <= 1.0)) {
		tmp = (x_m / z) * (y_m / (z * z));
	} else {
		tmp = y_m / (z * (z / x_m));
	}
	return y_s * (x_s * tmp);
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((z <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
        tmp = (x_m / z) * (y_m / (z * z))
    else
        tmp = y_m / (z * (z / x_m))
    end if
    code = y_s * (x_s * tmp)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
	double tmp;
	if ((z <= -1.0) || !(z <= 1.0)) {
		tmp = (x_m / z) * (y_m / (z * z));
	} else {
		tmp = y_m / (z * (z / x_m));
	}
	return y_s * (x_s * tmp);
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x_m, y_m, z] = sort([x_m, y_m, z])
def code(y_s, x_s, x_m, y_m, z):
	tmp = 0
	if (z <= -1.0) or not (z <= 1.0):
		tmp = (x_m / z) * (y_m / (z * z))
	else:
		tmp = y_m / (z * (z / x_m))
	return y_s * (x_s * tmp)
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x_m, y_m, z = sort([x_m, y_m, z])
function code(y_s, x_s, x_m, y_m, z)
	tmp = 0.0
	if ((z <= -1.0) || !(z <= 1.0))
		tmp = Float64(Float64(x_m / z) * Float64(y_m / Float64(z * z)));
	else
		tmp = Float64(y_m / Float64(z * Float64(z / x_m)));
	end
	return Float64(y_s * Float64(x_s * tmp))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z)
	tmp = 0.0;
	if ((z <= -1.0) || ~((z <= 1.0)))
		tmp = (x_m / z) * (y_m / (z * z));
	else
		tmp = y_m / (z * (z / x_m));
	end
	tmp_2 = y_s * (x_s * tmp);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(N[(x$95$m / z), $MachinePrecision] * N[(y$95$m / N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y$95$m / N[(z * N[(z / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;\frac{x\_m}{z} \cdot \frac{y\_m}{z \cdot z}\\

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


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

    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. sqr-neg80.7%

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

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

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

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

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

    if -1 < z < 1

    1. Initial program 76.3%

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

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \frac{\frac{x}{z \cdot z}}{z + 1}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. associate-*r/80.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{x}{z} \cdot \frac{y}{z + 1}}{z}} \]
    7. Step-by-step derivation
      1. *-commutative95.4%

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

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

      \[\leadsto \color{blue}{\frac{y}{z + 1} \cdot \frac{\frac{x}{z}}{z}} \]
    9. Step-by-step derivation
      1. clear-num89.1%

        \[\leadsto \frac{y}{z + 1} \cdot \color{blue}{\frac{1}{\frac{z}{\frac{x}{z}}}} \]
      2. un-div-inv90.9%

        \[\leadsto \color{blue}{\frac{\frac{y}{z + 1}}{\frac{z}{\frac{x}{z}}}} \]
      3. div-inv90.9%

        \[\leadsto \frac{\frac{y}{z + 1}}{\color{blue}{z \cdot \frac{1}{\frac{x}{z}}}} \]
      4. clear-num90.9%

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

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

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

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

Alternative 5: 90.6% accurate, 0.6× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\ \\ y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\ \;\;\;\;y\_m \cdot \frac{\frac{x\_m}{z \cdot z}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y\_m}{z \cdot \frac{z}{x\_m}}\\ \end{array}\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
 :precision binary64
 (*
  y_s
  (*
   x_s
   (if (or (<= z -1.0) (not (<= z 1.0)))
     (* y_m (/ (/ x_m (* z z)) z))
     (/ y_m (* z (/ z x_m)))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
	double tmp;
	if ((z <= -1.0) || !(z <= 1.0)) {
		tmp = y_m * ((x_m / (z * z)) / z);
	} else {
		tmp = y_m / (z * (z / x_m));
	}
	return y_s * (x_s * tmp);
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((z <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
        tmp = y_m * ((x_m / (z * z)) / z)
    else
        tmp = y_m / (z * (z / x_m))
    end if
    code = y_s * (x_s * tmp)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
	double tmp;
	if ((z <= -1.0) || !(z <= 1.0)) {
		tmp = y_m * ((x_m / (z * z)) / z);
	} else {
		tmp = y_m / (z * (z / x_m));
	}
	return y_s * (x_s * tmp);
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x_m, y_m, z] = sort([x_m, y_m, z])
def code(y_s, x_s, x_m, y_m, z):
	tmp = 0
	if (z <= -1.0) or not (z <= 1.0):
		tmp = y_m * ((x_m / (z * z)) / z)
	else:
		tmp = y_m / (z * (z / x_m))
	return y_s * (x_s * tmp)
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x_m, y_m, z = sort([x_m, y_m, z])
function code(y_s, x_s, x_m, y_m, z)
	tmp = 0.0
	if ((z <= -1.0) || !(z <= 1.0))
		tmp = Float64(y_m * Float64(Float64(x_m / Float64(z * z)) / z));
	else
		tmp = Float64(y_m / Float64(z * Float64(z / x_m)));
	end
	return Float64(y_s * Float64(x_s * tmp))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z)
	tmp = 0.0;
	if ((z <= -1.0) || ~((z <= 1.0)))
		tmp = y_m * ((x_m / (z * z)) / z);
	else
		tmp = y_m / (z * (z / x_m));
	end
	tmp_2 = y_s * (x_s * tmp);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(y$95$m * N[(N[(x$95$m / N[(z * z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(y$95$m / N[(z * N[(z / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;y\_m \cdot \frac{\frac{x\_m}{z \cdot z}}{z}\\

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


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

    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*84.8%

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

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

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

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

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

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

    if -1 < z < 1

    1. Initial program 76.3%

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

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \frac{\frac{x}{z \cdot z}}{z + 1}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. associate-*r/80.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{x}{z} \cdot \frac{y}{z + 1}}{z}} \]
    7. Step-by-step derivation
      1. *-commutative95.4%

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

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

      \[\leadsto \color{blue}{\frac{y}{z + 1} \cdot \frac{\frac{x}{z}}{z}} \]
    9. Step-by-step derivation
      1. clear-num89.1%

        \[\leadsto \frac{y}{z + 1} \cdot \color{blue}{\frac{1}{\frac{z}{\frac{x}{z}}}} \]
      2. un-div-inv90.9%

        \[\leadsto \color{blue}{\frac{\frac{y}{z + 1}}{\frac{z}{\frac{x}{z}}}} \]
      3. div-inv90.9%

        \[\leadsto \frac{\frac{y}{z + 1}}{\color{blue}{z \cdot \frac{1}{\frac{x}{z}}}} \]
      4. clear-num90.9%

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

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

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

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

Alternative 6: 96.2% accurate, 0.6× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\ \\ y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq -3.5 \cdot 10^{-7}:\\ \;\;\;\;\frac{y\_m}{z \cdot z} \cdot \frac{x\_m}{z + 1}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{y\_m}{z \cdot \frac{z}{x\_m}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{x\_m}{z}}{\frac{z}{y\_m}}}{z}\\ \end{array}\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
 :precision binary64
 (*
  y_s
  (*
   x_s
   (if (<= z -3.5e-7)
     (* (/ y_m (* z z)) (/ x_m (+ z 1.0)))
     (if (<= z 1.0) (/ y_m (* z (/ z x_m))) (/ (/ (/ x_m z) (/ z y_m)) z))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
	double tmp;
	if (z <= -3.5e-7) {
		tmp = (y_m / (z * z)) * (x_m / (z + 1.0));
	} else if (z <= 1.0) {
		tmp = y_m / (z * (z / x_m));
	} else {
		tmp = ((x_m / z) / (z / y_m)) / z;
	}
	return y_s * (x_s * tmp);
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-3.5d-7)) then
        tmp = (y_m / (z * z)) * (x_m / (z + 1.0d0))
    else if (z <= 1.0d0) then
        tmp = y_m / (z * (z / x_m))
    else
        tmp = ((x_m / z) / (z / y_m)) / z
    end if
    code = y_s * (x_s * tmp)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
	double tmp;
	if (z <= -3.5e-7) {
		tmp = (y_m / (z * z)) * (x_m / (z + 1.0));
	} else if (z <= 1.0) {
		tmp = y_m / (z * (z / x_m));
	} else {
		tmp = ((x_m / z) / (z / y_m)) / z;
	}
	return y_s * (x_s * tmp);
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x_m, y_m, z] = sort([x_m, y_m, z])
def code(y_s, x_s, x_m, y_m, z):
	tmp = 0
	if z <= -3.5e-7:
		tmp = (y_m / (z * z)) * (x_m / (z + 1.0))
	elif z <= 1.0:
		tmp = y_m / (z * (z / x_m))
	else:
		tmp = ((x_m / z) / (z / y_m)) / z
	return y_s * (x_s * tmp)
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x_m, y_m, z = sort([x_m, y_m, z])
function code(y_s, x_s, x_m, y_m, z)
	tmp = 0.0
	if (z <= -3.5e-7)
		tmp = Float64(Float64(y_m / Float64(z * z)) * Float64(x_m / Float64(z + 1.0)));
	elseif (z <= 1.0)
		tmp = Float64(y_m / Float64(z * Float64(z / x_m)));
	else
		tmp = Float64(Float64(Float64(x_m / z) / Float64(z / y_m)) / z);
	end
	return Float64(y_s * Float64(x_s * tmp))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z)
	tmp = 0.0;
	if (z <= -3.5e-7)
		tmp = (y_m / (z * z)) * (x_m / (z + 1.0));
	elseif (z <= 1.0)
		tmp = y_m / (z * (z / x_m));
	else
		tmp = ((x_m / z) / (z / y_m)) / z;
	end
	tmp_2 = y_s * (x_s * tmp);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[LessEqual[z, -3.5e-7], N[(N[(y$95$m / N[(z * z), $MachinePrecision]), $MachinePrecision] * N[(x$95$m / N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.0], N[(y$95$m / N[(z * N[(z / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$95$m / z), $MachinePrecision] / N[(z / y$95$m), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -3.5 \cdot 10^{-7}:\\
\;\;\;\;\frac{y\_m}{z \cdot z} \cdot \frac{x\_m}{z + 1}\\

\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{y\_m}{z \cdot \frac{z}{x\_m}}\\

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


\end{array}\right)
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -3.49999999999999984e-7

    1. Initial program 80.0%

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

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

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

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

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

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

    if -3.49999999999999984e-7 < z < 1

    1. Initial program 76.1%

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

        \[\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}{y \cdot \frac{x}{\left(z \cdot z\right) \cdot \left(z + 1\right)}} \]
      3. sqr-neg80.5%

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

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

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

      \[\leadsto \color{blue}{y \cdot \frac{\frac{x}{z \cdot z}}{z + 1}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. associate-*r/80.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{x}{z} \cdot \frac{y}{z + 1}}{z}} \]
    7. Step-by-step derivation
      1. *-commutative95.3%

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

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

      \[\leadsto \color{blue}{\frac{y}{z + 1} \cdot \frac{\frac{x}{z}}{z}} \]
    9. Step-by-step derivation
      1. clear-num89.1%

        \[\leadsto \frac{y}{z + 1} \cdot \color{blue}{\frac{1}{\frac{z}{\frac{x}{z}}}} \]
      2. un-div-inv90.9%

        \[\leadsto \color{blue}{\frac{\frac{y}{z + 1}}{\frac{z}{\frac{x}{z}}}} \]
      3. div-inv90.8%

        \[\leadsto \frac{\frac{y}{z + 1}}{\color{blue}{z \cdot \frac{1}{\frac{x}{z}}}} \]
      4. clear-num90.9%

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

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

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

    if 1 < z

    1. Initial program 81.8%

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

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \frac{\frac{x}{z \cdot z}}{z + 1}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. associate-*r/88.7%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{x}{z} \cdot \frac{y}{z + 1}}{z}} \]
    7. Step-by-step derivation
      1. clear-num99.8%

        \[\leadsto \frac{\frac{x}{z} \cdot \color{blue}{\frac{1}{\frac{z + 1}{y}}}}{z} \]
      2. un-div-inv99.8%

        \[\leadsto \frac{\color{blue}{\frac{\frac{x}{z}}{\frac{z + 1}{y}}}}{z} \]
    8. Applied egg-rr99.8%

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

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

Alternative 7: 96.4% accurate, 0.6× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\ \\ y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;\frac{\frac{x\_m}{z} \cdot \frac{y\_m}{z}}{z}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{y\_m}{z \cdot \frac{z}{x\_m}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{x\_m}{z}}{\frac{z}{y\_m}}}{z}\\ \end{array}\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
 :precision binary64
 (*
  y_s
  (*
   x_s
   (if (<= z -1.0)
     (/ (* (/ x_m z) (/ y_m z)) z)
     (if (<= z 1.0) (/ y_m (* z (/ z x_m))) (/ (/ (/ x_m z) (/ z y_m)) z))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
	double tmp;
	if (z <= -1.0) {
		tmp = ((x_m / z) * (y_m / z)) / z;
	} else if (z <= 1.0) {
		tmp = y_m / (z * (z / x_m));
	} else {
		tmp = ((x_m / z) / (z / y_m)) / z;
	}
	return y_s * (x_s * tmp);
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-1.0d0)) then
        tmp = ((x_m / z) * (y_m / z)) / z
    else if (z <= 1.0d0) then
        tmp = y_m / (z * (z / x_m))
    else
        tmp = ((x_m / z) / (z / y_m)) / z
    end if
    code = y_s * (x_s * tmp)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
	double tmp;
	if (z <= -1.0) {
		tmp = ((x_m / z) * (y_m / z)) / z;
	} else if (z <= 1.0) {
		tmp = y_m / (z * (z / x_m));
	} else {
		tmp = ((x_m / z) / (z / y_m)) / z;
	}
	return y_s * (x_s * tmp);
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x_m, y_m, z] = sort([x_m, y_m, z])
def code(y_s, x_s, x_m, y_m, z):
	tmp = 0
	if z <= -1.0:
		tmp = ((x_m / z) * (y_m / z)) / z
	elif z <= 1.0:
		tmp = y_m / (z * (z / x_m))
	else:
		tmp = ((x_m / z) / (z / y_m)) / z
	return y_s * (x_s * tmp)
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x_m, y_m, z = sort([x_m, y_m, z])
function code(y_s, x_s, x_m, y_m, z)
	tmp = 0.0
	if (z <= -1.0)
		tmp = Float64(Float64(Float64(x_m / z) * Float64(y_m / z)) / z);
	elseif (z <= 1.0)
		tmp = Float64(y_m / Float64(z * Float64(z / x_m)));
	else
		tmp = Float64(Float64(Float64(x_m / z) / Float64(z / y_m)) / z);
	end
	return Float64(y_s * Float64(x_s * tmp))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z)
	tmp = 0.0;
	if (z <= -1.0)
		tmp = ((x_m / z) * (y_m / z)) / z;
	elseif (z <= 1.0)
		tmp = y_m / (z * (z / x_m));
	else
		tmp = ((x_m / z) / (z / y_m)) / z;
	end
	tmp_2 = y_s * (x_s * tmp);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[LessEqual[z, -1.0], N[(N[(N[(x$95$m / z), $MachinePrecision] * N[(y$95$m / z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 1.0], N[(y$95$m / N[(z * N[(z / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$95$m / z), $MachinePrecision] / N[(z / y$95$m), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;\frac{\frac{x\_m}{z} \cdot \frac{y\_m}{z}}{z}\\

\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{y\_m}{z \cdot \frac{z}{x\_m}}\\

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


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

    1. Initial program 79.7%

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

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \frac{\frac{x}{z \cdot z}}{z + 1}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. associate-*r/94.0%

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

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

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

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

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

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

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

    if -1 < z < 1

    1. Initial program 76.3%

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

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \frac{\frac{x}{z \cdot z}}{z + 1}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. associate-*r/80.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{x}{z} \cdot \frac{y}{z + 1}}{z}} \]
    7. Step-by-step derivation
      1. *-commutative95.4%

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

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

      \[\leadsto \color{blue}{\frac{y}{z + 1} \cdot \frac{\frac{x}{z}}{z}} \]
    9. Step-by-step derivation
      1. clear-num89.1%

        \[\leadsto \frac{y}{z + 1} \cdot \color{blue}{\frac{1}{\frac{z}{\frac{x}{z}}}} \]
      2. un-div-inv90.9%

        \[\leadsto \color{blue}{\frac{\frac{y}{z + 1}}{\frac{z}{\frac{x}{z}}}} \]
      3. div-inv90.9%

        \[\leadsto \frac{\frac{y}{z + 1}}{\color{blue}{z \cdot \frac{1}{\frac{x}{z}}}} \]
      4. clear-num90.9%

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

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

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

    if 1 < z

    1. Initial program 81.8%

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

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \frac{\frac{x}{z \cdot z}}{z + 1}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. associate-*r/88.7%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{x}{z} \cdot \frac{y}{z + 1}}{z}} \]
    7. Step-by-step derivation
      1. clear-num99.8%

        \[\leadsto \frac{\frac{x}{z} \cdot \color{blue}{\frac{1}{\frac{z + 1}{y}}}}{z} \]
      2. un-div-inv99.8%

        \[\leadsto \frac{\color{blue}{\frac{\frac{x}{z}}{\frac{z + 1}{y}}}}{z} \]
    8. Applied egg-rr99.8%

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

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

Alternative 8: 42.9% accurate, 0.7× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\ \\ y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{x\_m}{z} \cdot \left(-y\_m\right)\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{-142}:\\ \;\;\;\;x\_m \cdot \frac{y\_m}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y\_m}{\frac{z}{x\_m}}\\ \end{array}\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
 :precision binary64
 (*
  y_s
  (*
   x_s
   (if (<= z -5e-310)
     (* (/ x_m z) (- y_m))
     (if (<= z 3.2e-142) (* x_m (/ y_m z)) (/ y_m (/ z x_m)))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
	double tmp;
	if (z <= -5e-310) {
		tmp = (x_m / z) * -y_m;
	} else if (z <= 3.2e-142) {
		tmp = x_m * (y_m / z);
	} else {
		tmp = y_m / (z / x_m);
	}
	return y_s * (x_s * tmp);
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-5d-310)) then
        tmp = (x_m / z) * -y_m
    else if (z <= 3.2d-142) then
        tmp = x_m * (y_m / z)
    else
        tmp = y_m / (z / x_m)
    end if
    code = y_s * (x_s * tmp)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
	double tmp;
	if (z <= -5e-310) {
		tmp = (x_m / z) * -y_m;
	} else if (z <= 3.2e-142) {
		tmp = x_m * (y_m / z);
	} else {
		tmp = y_m / (z / x_m);
	}
	return y_s * (x_s * tmp);
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x_m, y_m, z] = sort([x_m, y_m, z])
def code(y_s, x_s, x_m, y_m, z):
	tmp = 0
	if z <= -5e-310:
		tmp = (x_m / z) * -y_m
	elif z <= 3.2e-142:
		tmp = x_m * (y_m / z)
	else:
		tmp = y_m / (z / x_m)
	return y_s * (x_s * tmp)
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x_m, y_m, z = sort([x_m, y_m, z])
function code(y_s, x_s, x_m, y_m, z)
	tmp = 0.0
	if (z <= -5e-310)
		tmp = Float64(Float64(x_m / z) * Float64(-y_m));
	elseif (z <= 3.2e-142)
		tmp = Float64(x_m * Float64(y_m / z));
	else
		tmp = Float64(y_m / Float64(z / x_m));
	end
	return Float64(y_s * Float64(x_s * tmp))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z)
	tmp = 0.0;
	if (z <= -5e-310)
		tmp = (x_m / z) * -y_m;
	elseif (z <= 3.2e-142)
		tmp = x_m * (y_m / z);
	else
		tmp = y_m / (z / x_m);
	end
	tmp_2 = y_s * (x_s * tmp);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[LessEqual[z, -5e-310], N[(N[(x$95$m / z), $MachinePrecision] * (-y$95$m)), $MachinePrecision], If[LessEqual[z, 3.2e-142], N[(x$95$m * N[(y$95$m / z), $MachinePrecision]), $MachinePrecision], N[(y$95$m / N[(z / x$95$m), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{x\_m}{z} \cdot \left(-y\_m\right)\\

\mathbf{elif}\;z \leq 3.2 \cdot 10^{-142}:\\
\;\;\;\;x\_m \cdot \frac{y\_m}{z}\\

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


\end{array}\right)
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -4.999999999999985e-310

    1. Initial program 76.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{y}{z \cdot z} \cdot \color{blue}{\left(x - x \cdot z\right)} \]
    8. Taylor expanded in z around inf 40.8%

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot y}{z}} \]
    9. Step-by-step derivation
      1. mul-1-neg40.8%

        \[\leadsto \color{blue}{-\frac{x \cdot y}{z}} \]
      2. associate-*l/45.3%

        \[\leadsto -\color{blue}{\frac{x}{z} \cdot y} \]
      3. *-commutative45.3%

        \[\leadsto -\color{blue}{y \cdot \frac{x}{z}} \]
      4. distribute-rgt-neg-in45.3%

        \[\leadsto \color{blue}{y \cdot \left(-\frac{x}{z}\right)} \]
      5. distribute-frac-neg245.3%

        \[\leadsto y \cdot \color{blue}{\frac{x}{-z}} \]
    10. Simplified45.3%

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

    if -4.999999999999985e-310 < z < 3.1999999999999998e-142

    1. Initial program 69.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{y}{z \cdot z} \cdot \color{blue}{\left(x - x \cdot z\right)} \]
    8. Taylor expanded in z around inf 0.6%

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot y}{z}} \]
    9. Step-by-step derivation
      1. mul-1-neg0.6%

        \[\leadsto \color{blue}{-\frac{x \cdot y}{z}} \]
      2. associate-*l/0.5%

        \[\leadsto -\color{blue}{\frac{x}{z} \cdot y} \]
      3. *-commutative0.5%

        \[\leadsto -\color{blue}{y \cdot \frac{x}{z}} \]
      4. distribute-rgt-neg-in0.5%

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

        \[\leadsto y \cdot \color{blue}{\frac{x}{-z}} \]
    10. Simplified0.5%

      \[\leadsto \color{blue}{y \cdot \frac{x}{-z}} \]
    11. Step-by-step derivation
      1. distribute-frac-neg20.5%

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

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

        \[\leadsto \color{blue}{\frac{y \cdot \left(-x\right)}{z}} \]
    12. Applied egg-rr0.6%

      \[\leadsto \color{blue}{\frac{y \cdot \left(-x\right)}{z}} \]
    13. Step-by-step derivation
      1. add-sqr-sqrt0.6%

        \[\leadsto \frac{y \cdot \left(-x\right)}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}} \]
      2. times-frac0.5%

        \[\leadsto \color{blue}{\frac{y}{\sqrt{z}} \cdot \frac{-x}{\sqrt{z}}} \]
      3. add-sqr-sqrt0.4%

        \[\leadsto \frac{y}{\sqrt{z}} \cdot \frac{\color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{\sqrt{z}} \]
      4. sqrt-unprod22.0%

        \[\leadsto \frac{y}{\sqrt{z}} \cdot \frac{\color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}{\sqrt{z}} \]
      5. sqr-neg22.0%

        \[\leadsto \frac{y}{\sqrt{z}} \cdot \frac{\sqrt{\color{blue}{x \cdot x}}}{\sqrt{z}} \]
      6. sqrt-unprod19.6%

        \[\leadsto \frac{y}{\sqrt{z}} \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{\sqrt{z}} \]
      7. add-sqr-sqrt32.9%

        \[\leadsto \frac{y}{\sqrt{z}} \cdot \frac{\color{blue}{x}}{\sqrt{z}} \]
      8. times-frac22.3%

        \[\leadsto \color{blue}{\frac{y \cdot x}{\sqrt{z} \cdot \sqrt{z}}} \]
      9. add-sqr-sqrt22.3%

        \[\leadsto \frac{y \cdot x}{\color{blue}{z}} \]
      10. clear-num22.3%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{z}{y}}{x}}} \]
      12. associate-/r/37.3%

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

        \[\leadsto \color{blue}{\frac{y}{z}} \cdot x \]
    14. Applied egg-rr37.3%

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

    if 3.1999999999999998e-142 < z

    1. Initial program 85.5%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. 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. sqr-neg85.5%

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

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

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

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

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

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

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

      \[\leadsto \frac{y}{z \cdot z} \cdot \color{blue}{\left(x - x \cdot z\right)} \]
    8. Taylor expanded in z around inf 19.0%

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot y}{z}} \]
    9. Step-by-step derivation
      1. mul-1-neg19.0%

        \[\leadsto \color{blue}{-\frac{x \cdot y}{z}} \]
      2. associate-*l/20.2%

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

        \[\leadsto -\color{blue}{y \cdot \frac{x}{z}} \]
      4. distribute-rgt-neg-in20.2%

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

        \[\leadsto y \cdot \color{blue}{\frac{x}{-z}} \]
    10. Simplified20.2%

      \[\leadsto \color{blue}{y \cdot \frac{x}{-z}} \]
    11. Step-by-step derivation
      1. add-sqr-sqrt18.0%

        \[\leadsto y \cdot \color{blue}{\left(\sqrt{\frac{x}{-z}} \cdot \sqrt{\frac{x}{-z}}\right)} \]
      2. sqrt-unprod37.2%

        \[\leadsto y \cdot \color{blue}{\sqrt{\frac{x}{-z} \cdot \frac{x}{-z}}} \]
      3. distribute-frac-neg237.2%

        \[\leadsto y \cdot \sqrt{\color{blue}{\left(-\frac{x}{z}\right)} \cdot \frac{x}{-z}} \]
      4. distribute-frac-neg237.2%

        \[\leadsto y \cdot \sqrt{\left(-\frac{x}{z}\right) \cdot \color{blue}{\left(-\frac{x}{z}\right)}} \]
      5. sqr-neg37.2%

        \[\leadsto y \cdot \sqrt{\color{blue}{\frac{x}{z} \cdot \frac{x}{z}}} \]
      6. sqrt-unprod24.2%

        \[\leadsto y \cdot \color{blue}{\left(\sqrt{\frac{x}{z}} \cdot \sqrt{\frac{x}{z}}\right)} \]
      7. add-sqr-sqrt33.7%

        \[\leadsto y \cdot \color{blue}{\frac{x}{z}} \]
      8. clear-num33.7%

        \[\leadsto y \cdot \color{blue}{\frac{1}{\frac{z}{x}}} \]
      9. un-div-inv33.7%

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}} \]
    12. Applied egg-rr33.7%

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

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

Alternative 9: 35.1% accurate, 0.7× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\ \\ y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq -6.8 \cdot 10^{-308}:\\ \;\;\;\;\frac{x\_m}{z} \cdot y\_m\\ \mathbf{elif}\;z \leq 1.04 \cdot 10^{-168}:\\ \;\;\;\;x\_m \cdot \frac{y\_m}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y\_m}{\frac{z}{x\_m}}\\ \end{array}\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
 :precision binary64
 (*
  y_s
  (*
   x_s
   (if (<= z -6.8e-308)
     (* (/ x_m z) y_m)
     (if (<= z 1.04e-168) (* x_m (/ y_m z)) (/ y_m (/ z x_m)))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
	double tmp;
	if (z <= -6.8e-308) {
		tmp = (x_m / z) * y_m;
	} else if (z <= 1.04e-168) {
		tmp = x_m * (y_m / z);
	} else {
		tmp = y_m / (z / x_m);
	}
	return y_s * (x_s * tmp);
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-6.8d-308)) then
        tmp = (x_m / z) * y_m
    else if (z <= 1.04d-168) then
        tmp = x_m * (y_m / z)
    else
        tmp = y_m / (z / x_m)
    end if
    code = y_s * (x_s * tmp)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
	double tmp;
	if (z <= -6.8e-308) {
		tmp = (x_m / z) * y_m;
	} else if (z <= 1.04e-168) {
		tmp = x_m * (y_m / z);
	} else {
		tmp = y_m / (z / x_m);
	}
	return y_s * (x_s * tmp);
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x_m, y_m, z] = sort([x_m, y_m, z])
def code(y_s, x_s, x_m, y_m, z):
	tmp = 0
	if z <= -6.8e-308:
		tmp = (x_m / z) * y_m
	elif z <= 1.04e-168:
		tmp = x_m * (y_m / z)
	else:
		tmp = y_m / (z / x_m)
	return y_s * (x_s * tmp)
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x_m, y_m, z = sort([x_m, y_m, z])
function code(y_s, x_s, x_m, y_m, z)
	tmp = 0.0
	if (z <= -6.8e-308)
		tmp = Float64(Float64(x_m / z) * y_m);
	elseif (z <= 1.04e-168)
		tmp = Float64(x_m * Float64(y_m / z));
	else
		tmp = Float64(y_m / Float64(z / x_m));
	end
	return Float64(y_s * Float64(x_s * tmp))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z)
	tmp = 0.0;
	if (z <= -6.8e-308)
		tmp = (x_m / z) * y_m;
	elseif (z <= 1.04e-168)
		tmp = x_m * (y_m / z);
	else
		tmp = y_m / (z / x_m);
	end
	tmp_2 = y_s * (x_s * tmp);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[LessEqual[z, -6.8e-308], N[(N[(x$95$m / z), $MachinePrecision] * y$95$m), $MachinePrecision], If[LessEqual[z, 1.04e-168], N[(x$95$m * N[(y$95$m / z), $MachinePrecision]), $MachinePrecision], N[(y$95$m / N[(z / x$95$m), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -6.8 \cdot 10^{-308}:\\
\;\;\;\;\frac{x\_m}{z} \cdot y\_m\\

\mathbf{elif}\;z \leq 1.04 \cdot 10^{-168}:\\
\;\;\;\;x\_m \cdot \frac{y\_m}{z}\\

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


\end{array}\right)
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -6.79999999999999998e-308

    1. Initial program 77.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{y}{z \cdot z} \cdot \color{blue}{\left(x - x \cdot z\right)} \]
    8. Taylor expanded in z around inf 41.1%

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot y}{z}} \]
    9. Step-by-step derivation
      1. mul-1-neg41.1%

        \[\leadsto \color{blue}{-\frac{x \cdot y}{z}} \]
      2. associate-*l/45.6%

        \[\leadsto -\color{blue}{\frac{x}{z} \cdot y} \]
      3. *-commutative45.6%

        \[\leadsto -\color{blue}{y \cdot \frac{x}{z}} \]
      4. distribute-rgt-neg-in45.6%

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

        \[\leadsto y \cdot \color{blue}{\frac{x}{-z}} \]
    10. Simplified45.6%

      \[\leadsto \color{blue}{y \cdot \frac{x}{-z}} \]
    11. Step-by-step derivation
      1. add-sqr-sqrt27.0%

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

        \[\leadsto y \cdot \color{blue}{\sqrt{\frac{x}{-z} \cdot \frac{x}{-z}}} \]
      3. distribute-frac-neg243.9%

        \[\leadsto y \cdot \sqrt{\color{blue}{\left(-\frac{x}{z}\right)} \cdot \frac{x}{-z}} \]
      4. distribute-frac-neg243.9%

        \[\leadsto y \cdot \sqrt{\left(-\frac{x}{z}\right) \cdot \color{blue}{\left(-\frac{x}{z}\right)}} \]
      5. sqr-neg43.9%

        \[\leadsto y \cdot \sqrt{\color{blue}{\frac{x}{z} \cdot \frac{x}{z}}} \]
      6. sqrt-unprod20.7%

        \[\leadsto y \cdot \color{blue}{\left(\sqrt{\frac{x}{z}} \cdot \sqrt{\frac{x}{z}}\right)} \]
      7. add-sqr-sqrt25.6%

        \[\leadsto y \cdot \color{blue}{\frac{x}{z}} \]
      8. *-un-lft-identity25.6%

        \[\leadsto y \cdot \color{blue}{\left(1 \cdot \frac{x}{z}\right)} \]
    12. Applied egg-rr25.6%

      \[\leadsto y \cdot \color{blue}{\left(1 \cdot \frac{x}{z}\right)} \]
    13. Step-by-step derivation
      1. *-lft-identity25.6%

        \[\leadsto y \cdot \color{blue}{\frac{x}{z}} \]
    14. Simplified25.6%

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

    if -6.79999999999999998e-308 < z < 1.04000000000000006e-168

    1. Initial program 70.5%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{y}{z \cdot z} \cdot \color{blue}{\left(x - x \cdot z\right)} \]
    8. Taylor expanded in z around inf 0.6%

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot y}{z}} \]
    9. Step-by-step derivation
      1. mul-1-neg0.6%

        \[\leadsto \color{blue}{-\frac{x \cdot y}{z}} \]
      2. associate-*l/0.5%

        \[\leadsto -\color{blue}{\frac{x}{z} \cdot y} \]
      3. *-commutative0.5%

        \[\leadsto -\color{blue}{y \cdot \frac{x}{z}} \]
      4. distribute-rgt-neg-in0.5%

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

        \[\leadsto y \cdot \color{blue}{\frac{x}{-z}} \]
    10. Simplified0.5%

      \[\leadsto \color{blue}{y \cdot \frac{x}{-z}} \]
    11. Step-by-step derivation
      1. distribute-frac-neg20.5%

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

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

        \[\leadsto \color{blue}{\frac{y \cdot \left(-x\right)}{z}} \]
    12. Applied egg-rr0.6%

      \[\leadsto \color{blue}{\frac{y \cdot \left(-x\right)}{z}} \]
    13. Step-by-step derivation
      1. add-sqr-sqrt0.5%

        \[\leadsto \frac{y \cdot \left(-x\right)}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}} \]
      2. times-frac0.5%

        \[\leadsto \color{blue}{\frac{y}{\sqrt{z}} \cdot \frac{-x}{\sqrt{z}}} \]
      3. add-sqr-sqrt0.3%

        \[\leadsto \frac{y}{\sqrt{z}} \cdot \frac{\color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{\sqrt{z}} \]
      4. sqrt-unprod22.9%

        \[\leadsto \frac{y}{\sqrt{z}} \cdot \frac{\color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}{\sqrt{z}} \]
      5. sqr-neg22.9%

        \[\leadsto \frac{y}{\sqrt{z}} \cdot \frac{\sqrt{\color{blue}{x \cdot x}}}{\sqrt{z}} \]
      6. sqrt-unprod20.5%

        \[\leadsto \frac{y}{\sqrt{z}} \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{\sqrt{z}} \]
      7. add-sqr-sqrt34.2%

        \[\leadsto \frac{y}{\sqrt{z}} \cdot \frac{\color{blue}{x}}{\sqrt{z}} \]
      8. times-frac23.1%

        \[\leadsto \color{blue}{\frac{y \cdot x}{\sqrt{z} \cdot \sqrt{z}}} \]
      9. add-sqr-sqrt23.1%

        \[\leadsto \frac{y \cdot x}{\color{blue}{z}} \]
      10. clear-num23.1%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{z}{y}}{x}}} \]
      12. associate-/r/38.8%

        \[\leadsto \color{blue}{\frac{1}{\frac{z}{y}} \cdot x} \]
      13. clear-num38.8%

        \[\leadsto \color{blue}{\frac{y}{z}} \cdot x \]
    14. Applied egg-rr38.8%

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

    if 1.04000000000000006e-168 < z

    1. Initial program 83.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{y}{z \cdot z} \cdot \color{blue}{\left(x - x \cdot z\right)} \]
    8. Taylor expanded in z around inf 18.4%

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot y}{z}} \]
    9. Step-by-step derivation
      1. mul-1-neg18.4%

        \[\leadsto \color{blue}{-\frac{x \cdot y}{z}} \]
      2. associate-*l/19.5%

        \[\leadsto -\color{blue}{\frac{x}{z} \cdot y} \]
      3. *-commutative19.5%

        \[\leadsto -\color{blue}{y \cdot \frac{x}{z}} \]
      4. distribute-rgt-neg-in19.5%

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

        \[\leadsto y \cdot \color{blue}{\frac{x}{-z}} \]
    10. Simplified19.5%

      \[\leadsto \color{blue}{y \cdot \frac{x}{-z}} \]
    11. Step-by-step derivation
      1. add-sqr-sqrt17.4%

        \[\leadsto y \cdot \color{blue}{\left(\sqrt{\frac{x}{-z}} \cdot \sqrt{\frac{x}{-z}}\right)} \]
      2. sqrt-unprod36.0%

        \[\leadsto y \cdot \color{blue}{\sqrt{\frac{x}{-z} \cdot \frac{x}{-z}}} \]
      3. distribute-frac-neg236.0%

        \[\leadsto y \cdot \sqrt{\color{blue}{\left(-\frac{x}{z}\right)} \cdot \frac{x}{-z}} \]
      4. distribute-frac-neg236.0%

        \[\leadsto y \cdot \sqrt{\left(-\frac{x}{z}\right) \cdot \color{blue}{\left(-\frac{x}{z}\right)}} \]
      5. sqr-neg36.0%

        \[\leadsto y \cdot \sqrt{\color{blue}{\frac{x}{z} \cdot \frac{x}{z}}} \]
      6. sqrt-unprod23.4%

        \[\leadsto y \cdot \color{blue}{\left(\sqrt{\frac{x}{z}} \cdot \sqrt{\frac{x}{z}}\right)} \]
      7. add-sqr-sqrt32.7%

        \[\leadsto y \cdot \color{blue}{\frac{x}{z}} \]
      8. clear-num32.7%

        \[\leadsto y \cdot \color{blue}{\frac{1}{\frac{z}{x}}} \]
      9. un-div-inv32.7%

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}} \]
    12. Applied egg-rr32.7%

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

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

Alternative 10: 97.9% accurate, 1.0× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\ \\ y\_s \cdot \left(x\_s \cdot \frac{\frac{\frac{x\_m}{z}}{\frac{z + 1}{y\_m}}}{z}\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
 :precision binary64
 (* y_s (* x_s (/ (/ (/ x_m z) (/ (+ z 1.0) y_m)) z))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
	return y_s * (x_s * (((x_m / z) / ((z + 1.0) / y_m)) / z));
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    code = y_s * (x_s * (((x_m / z) / ((z + 1.0d0) / y_m)) / z))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
	return y_s * (x_s * (((x_m / z) / ((z + 1.0) / y_m)) / z));
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x_m, y_m, z] = sort([x_m, y_m, z])
def code(y_s, x_s, x_m, y_m, z):
	return y_s * (x_s * (((x_m / z) / ((z + 1.0) / y_m)) / z))
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x_m, y_m, z = sort([x_m, y_m, z])
function code(y_s, x_s, x_m, y_m, z)
	return Float64(y_s * Float64(x_s * Float64(Float64(Float64(x_m / z) / Float64(Float64(z + 1.0) / y_m)) / z)))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp = code(y_s, x_s, x_m, y_m, z)
	tmp = y_s * (x_s * (((x_m / z) / ((z + 1.0) / y_m)) / z));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * N[(N[(N[(x$95$m / z), $MachinePrecision] / N[(N[(z + 1.0), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \frac{\frac{\frac{x\_m}{z}}{\frac{z + 1}{y\_m}}}{z}\right)
\end{array}
Derivation
  1. Initial program 78.4%

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

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

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

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

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

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

    \[\leadsto \color{blue}{y \cdot \frac{\frac{x}{z \cdot z}}{z + 1}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. associate-*r/85.9%

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{x}{z} \cdot \frac{y}{z + 1}}{z}} \]
  7. Step-by-step derivation
    1. clear-num97.1%

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

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

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

Alternative 11: 98.0% accurate, 1.0× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\ \\ y\_s \cdot \left(x\_s \cdot \frac{\frac{x\_m}{z} \cdot \frac{y\_m}{z + 1}}{z}\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
 :precision binary64
 (* y_s (* x_s (/ (* (/ x_m z) (/ y_m (+ z 1.0))) z))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
	return y_s * (x_s * (((x_m / z) * (y_m / (z + 1.0))) / z));
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    code = y_s * (x_s * (((x_m / z) * (y_m / (z + 1.0d0))) / z))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
	return y_s * (x_s * (((x_m / z) * (y_m / (z + 1.0))) / z));
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x_m, y_m, z] = sort([x_m, y_m, z])
def code(y_s, x_s, x_m, y_m, z):
	return y_s * (x_s * (((x_m / z) * (y_m / (z + 1.0))) / z))
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x_m, y_m, z = sort([x_m, y_m, z])
function code(y_s, x_s, x_m, y_m, z)
	return Float64(y_s * Float64(x_s * Float64(Float64(Float64(x_m / z) * Float64(y_m / Float64(z + 1.0))) / z)))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp = code(y_s, x_s, x_m, y_m, z)
	tmp = y_s * (x_s * (((x_m / z) * (y_m / (z + 1.0))) / z));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * N[(N[(N[(x$95$m / z), $MachinePrecision] * N[(y$95$m / N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \frac{\frac{x\_m}{z} \cdot \frac{y\_m}{z + 1}}{z}\right)
\end{array}
Derivation
  1. Initial program 78.4%

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

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

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

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

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

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

    \[\leadsto \color{blue}{y \cdot \frac{\frac{x}{z \cdot z}}{z + 1}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. associate-*r/85.9%

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

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

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

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

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

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

Alternative 12: 31.7% accurate, 1.1× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\ \\ y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq -6.8 \cdot 10^{-308}:\\ \;\;\;\;\frac{x\_m}{z} \cdot y\_m\\ \mathbf{else}:\\ \;\;\;\;x\_m \cdot \frac{y\_m}{z}\\ \end{array}\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
 :precision binary64
 (* y_s (* x_s (if (<= z -6.8e-308) (* (/ x_m z) y_m) (* x_m (/ y_m z))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
	double tmp;
	if (z <= -6.8e-308) {
		tmp = (x_m / z) * y_m;
	} else {
		tmp = x_m * (y_m / z);
	}
	return y_s * (x_s * tmp);
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-6.8d-308)) then
        tmp = (x_m / z) * y_m
    else
        tmp = x_m * (y_m / z)
    end if
    code = y_s * (x_s * tmp)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
	double tmp;
	if (z <= -6.8e-308) {
		tmp = (x_m / z) * y_m;
	} else {
		tmp = x_m * (y_m / z);
	}
	return y_s * (x_s * tmp);
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x_m, y_m, z] = sort([x_m, y_m, z])
def code(y_s, x_s, x_m, y_m, z):
	tmp = 0
	if z <= -6.8e-308:
		tmp = (x_m / z) * y_m
	else:
		tmp = x_m * (y_m / z)
	return y_s * (x_s * tmp)
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x_m, y_m, z = sort([x_m, y_m, z])
function code(y_s, x_s, x_m, y_m, z)
	tmp = 0.0
	if (z <= -6.8e-308)
		tmp = Float64(Float64(x_m / z) * y_m);
	else
		tmp = Float64(x_m * Float64(y_m / z));
	end
	return Float64(y_s * Float64(x_s * tmp))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z)
	tmp = 0.0;
	if (z <= -6.8e-308)
		tmp = (x_m / z) * y_m;
	else
		tmp = x_m * (y_m / z);
	end
	tmp_2 = y_s * (x_s * tmp);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[LessEqual[z, -6.8e-308], N[(N[(x$95$m / z), $MachinePrecision] * y$95$m), $MachinePrecision], N[(x$95$m * N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -6.8 \cdot 10^{-308}:\\
\;\;\;\;\frac{x\_m}{z} \cdot y\_m\\

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


\end{array}\right)
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -6.79999999999999998e-308

    1. Initial program 77.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{y}{z \cdot z} \cdot \color{blue}{\left(x - x \cdot z\right)} \]
    8. Taylor expanded in z around inf 41.1%

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot y}{z}} \]
    9. Step-by-step derivation
      1. mul-1-neg41.1%

        \[\leadsto \color{blue}{-\frac{x \cdot y}{z}} \]
      2. associate-*l/45.6%

        \[\leadsto -\color{blue}{\frac{x}{z} \cdot y} \]
      3. *-commutative45.6%

        \[\leadsto -\color{blue}{y \cdot \frac{x}{z}} \]
      4. distribute-rgt-neg-in45.6%

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

        \[\leadsto y \cdot \color{blue}{\frac{x}{-z}} \]
    10. Simplified45.6%

      \[\leadsto \color{blue}{y \cdot \frac{x}{-z}} \]
    11. Step-by-step derivation
      1. add-sqr-sqrt27.0%

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

        \[\leadsto y \cdot \color{blue}{\sqrt{\frac{x}{-z} \cdot \frac{x}{-z}}} \]
      3. distribute-frac-neg243.9%

        \[\leadsto y \cdot \sqrt{\color{blue}{\left(-\frac{x}{z}\right)} \cdot \frac{x}{-z}} \]
      4. distribute-frac-neg243.9%

        \[\leadsto y \cdot \sqrt{\left(-\frac{x}{z}\right) \cdot \color{blue}{\left(-\frac{x}{z}\right)}} \]
      5. sqr-neg43.9%

        \[\leadsto y \cdot \sqrt{\color{blue}{\frac{x}{z} \cdot \frac{x}{z}}} \]
      6. sqrt-unprod20.7%

        \[\leadsto y \cdot \color{blue}{\left(\sqrt{\frac{x}{z}} \cdot \sqrt{\frac{x}{z}}\right)} \]
      7. add-sqr-sqrt25.6%

        \[\leadsto y \cdot \color{blue}{\frac{x}{z}} \]
      8. *-un-lft-identity25.6%

        \[\leadsto y \cdot \color{blue}{\left(1 \cdot \frac{x}{z}\right)} \]
    12. Applied egg-rr25.6%

      \[\leadsto y \cdot \color{blue}{\left(1 \cdot \frac{x}{z}\right)} \]
    13. Step-by-step derivation
      1. *-lft-identity25.6%

        \[\leadsto y \cdot \color{blue}{\frac{x}{z}} \]
    14. Simplified25.6%

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

    if -6.79999999999999998e-308 < z

    1. Initial program 79.4%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{y}{z \cdot z} \cdot \color{blue}{\left(x - x \cdot z\right)} \]
    8. Taylor expanded in z around inf 12.6%

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot y}{z}} \]
    9. Step-by-step derivation
      1. mul-1-neg12.6%

        \[\leadsto \color{blue}{-\frac{x \cdot y}{z}} \]
      2. associate-*l/13.3%

        \[\leadsto -\color{blue}{\frac{x}{z} \cdot y} \]
      3. *-commutative13.3%

        \[\leadsto -\color{blue}{y \cdot \frac{x}{z}} \]
      4. distribute-rgt-neg-in13.3%

        \[\leadsto \color{blue}{y \cdot \left(-\frac{x}{z}\right)} \]
      5. distribute-frac-neg213.3%

        \[\leadsto y \cdot \color{blue}{\frac{x}{-z}} \]
    10. Simplified13.3%

      \[\leadsto \color{blue}{y \cdot \frac{x}{-z}} \]
    11. Step-by-step derivation
      1. distribute-frac-neg213.3%

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

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

        \[\leadsto \color{blue}{\frac{y \cdot \left(-x\right)}{z}} \]
    12. Applied egg-rr12.6%

      \[\leadsto \color{blue}{\frac{y \cdot \left(-x\right)}{z}} \]
    13. Step-by-step derivation
      1. add-sqr-sqrt12.6%

        \[\leadsto \frac{y \cdot \left(-x\right)}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}} \]
      2. times-frac12.6%

        \[\leadsto \color{blue}{\frac{y}{\sqrt{z}} \cdot \frac{-x}{\sqrt{z}}} \]
      3. add-sqr-sqrt5.7%

        \[\leadsto \frac{y}{\sqrt{z}} \cdot \frac{\color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{\sqrt{z}} \]
      4. sqrt-unprod27.8%

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

        \[\leadsto \frac{y}{\sqrt{z}} \cdot \frac{\sqrt{\color{blue}{x \cdot x}}}{\sqrt{z}} \]
      6. sqrt-unprod19.3%

        \[\leadsto \frac{y}{\sqrt{z}} \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{\sqrt{z}} \]
      7. add-sqr-sqrt32.5%

        \[\leadsto \frac{y}{\sqrt{z}} \cdot \frac{\color{blue}{x}}{\sqrt{z}} \]
      8. times-frac28.8%

        \[\leadsto \color{blue}{\frac{y \cdot x}{\sqrt{z} \cdot \sqrt{z}}} \]
      9. add-sqr-sqrt28.9%

        \[\leadsto \frac{y \cdot x}{\color{blue}{z}} \]
      10. clear-num28.9%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{z}{y}}{x}}} \]
      12. associate-/r/36.9%

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

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

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

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

Alternative 13: 80.8% accurate, 1.6× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\ \\ y\_s \cdot \left(x\_s \cdot \frac{y\_m}{z \cdot \frac{z}{x\_m}}\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
 :precision binary64
 (* y_s (* x_s (/ y_m (* z (/ z x_m))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
	return y_s * (x_s * (y_m / (z * (z / x_m))));
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    code = y_s * (x_s * (y_m / (z * (z / x_m))))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
	return y_s * (x_s * (y_m / (z * (z / x_m))));
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x_m, y_m, z] = sort([x_m, y_m, z])
def code(y_s, x_s, x_m, y_m, z):
	return y_s * (x_s * (y_m / (z * (z / x_m))))
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x_m, y_m, z = sort([x_m, y_m, z])
function code(y_s, x_s, x_m, y_m, z)
	return Float64(y_s * Float64(x_s * Float64(y_m / Float64(z * Float64(z / x_m)))))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp = code(y_s, x_s, x_m, y_m, z)
	tmp = y_s * (x_s * (y_m / (z * (z / x_m))));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * N[(y$95$m / N[(z * N[(z / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \frac{y\_m}{z \cdot \frac{z}{x\_m}}\right)
\end{array}
Derivation
  1. Initial program 78.4%

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

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

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

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

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

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

    \[\leadsto \color{blue}{y \cdot \frac{\frac{x}{z \cdot z}}{z + 1}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. associate-*r/85.9%

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{x}{z} \cdot \frac{y}{z + 1}}{z}} \]
  7. Step-by-step derivation
    1. *-commutative97.1%

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

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

    \[\leadsto \color{blue}{\frac{y}{z + 1} \cdot \frac{\frac{x}{z}}{z}} \]
  9. Step-by-step derivation
    1. clear-num91.7%

      \[\leadsto \frac{y}{z + 1} \cdot \color{blue}{\frac{1}{\frac{z}{\frac{x}{z}}}} \]
    2. un-div-inv92.6%

      \[\leadsto \color{blue}{\frac{\frac{y}{z + 1}}{\frac{z}{\frac{x}{z}}}} \]
    3. div-inv92.6%

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

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

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

    \[\leadsto \frac{\color{blue}{y}}{z \cdot \frac{z}{x}} \]
  12. Add Preprocessing

Alternative 14: 80.3% accurate, 1.6× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\ \\ y\_s \cdot \left(x\_s \cdot \left(y\_m \cdot \frac{\frac{x\_m}{z}}{z}\right)\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
 :precision binary64
 (* y_s (* x_s (* y_m (/ (/ x_m z) z)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
	return y_s * (x_s * (y_m * ((x_m / z) / z)));
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    code = y_s * (x_s * (y_m * ((x_m / z) / z)))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
	return y_s * (x_s * (y_m * ((x_m / z) / z)));
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x_m, y_m, z] = sort([x_m, y_m, z])
def code(y_s, x_s, x_m, y_m, z):
	return y_s * (x_s * (y_m * ((x_m / z) / z)))
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x_m, y_m, z = sort([x_m, y_m, z])
function code(y_s, x_s, x_m, y_m, z)
	return Float64(y_s * Float64(x_s * Float64(y_m * Float64(Float64(x_m / z) / z))))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp = code(y_s, x_s, x_m, y_m, z)
	tmp = y_s * (x_s * (y_m * ((x_m / z) / z)));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * N[(y$95$m * N[(N[(x$95$m / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \left(y\_m \cdot \frac{\frac{x\_m}{z}}{z}\right)\right)
\end{array}
Derivation
  1. Initial program 78.4%

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

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

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

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

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

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

    \[\leadsto \color{blue}{y \cdot \frac{\frac{x}{z \cdot z}}{z + 1}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. associate-*r/85.9%

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{x}{z} \cdot \frac{y}{z + 1}}{z}} \]
  7. Step-by-step derivation
    1. *-commutative97.1%

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

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

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

    \[\leadsto \color{blue}{y} \cdot \frac{\frac{x}{z}}{z} \]
  10. Add Preprocessing

Alternative 15: 32.5% accurate, 2.2× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\ \\ y\_s \cdot \left(x\_s \cdot \left(\frac{x\_m}{z} \cdot y\_m\right)\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
 :precision binary64
 (* y_s (* x_s (* (/ x_m z) y_m))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
	return y_s * (x_s * ((x_m / z) * y_m));
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    code = y_s * (x_s * ((x_m / z) * y_m))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
	return y_s * (x_s * ((x_m / z) * y_m));
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x_m, y_m, z] = sort([x_m, y_m, z])
def code(y_s, x_s, x_m, y_m, z):
	return y_s * (x_s * ((x_m / z) * y_m))
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x_m, y_m, z = sort([x_m, y_m, z])
function code(y_s, x_s, x_m, y_m, z)
	return Float64(y_s * Float64(x_s * Float64(Float64(x_m / z) * y_m)))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp = code(y_s, x_s, x_m, y_m, z)
	tmp = y_s * (x_s * ((x_m / z) * y_m));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * N[(N[(x$95$m / z), $MachinePrecision] * y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \left(\frac{x\_m}{z} \cdot y\_m\right)\right)
\end{array}
Derivation
  1. Initial program 78.4%

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

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

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

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

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

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

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

      \[\leadsto \frac{y}{z \cdot z} \cdot \left(x + \color{blue}{\left(-x \cdot z\right)}\right) \]
    2. unsub-neg64.0%

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

    \[\leadsto \frac{y}{z \cdot z} \cdot \color{blue}{\left(x - x \cdot z\right)} \]
  8. Taylor expanded in z around inf 26.7%

    \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot y}{z}} \]
  9. Step-by-step derivation
    1. mul-1-neg26.7%

      \[\leadsto \color{blue}{-\frac{x \cdot y}{z}} \]
    2. associate-*l/29.3%

      \[\leadsto -\color{blue}{\frac{x}{z} \cdot y} \]
    3. *-commutative29.3%

      \[\leadsto -\color{blue}{y \cdot \frac{x}{z}} \]
    4. distribute-rgt-neg-in29.3%

      \[\leadsto \color{blue}{y \cdot \left(-\frac{x}{z}\right)} \]
    5. distribute-frac-neg229.3%

      \[\leadsto y \cdot \color{blue}{\frac{x}{-z}} \]
  10. Simplified29.3%

    \[\leadsto \color{blue}{y \cdot \frac{x}{-z}} \]
  11. Step-by-step derivation
    1. add-sqr-sqrt19.4%

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

      \[\leadsto y \cdot \color{blue}{\sqrt{\frac{x}{-z} \cdot \frac{x}{-z}}} \]
    3. distribute-frac-neg239.3%

      \[\leadsto y \cdot \sqrt{\color{blue}{\left(-\frac{x}{z}\right)} \cdot \frac{x}{-z}} \]
    4. distribute-frac-neg239.3%

      \[\leadsto y \cdot \sqrt{\left(-\frac{x}{z}\right) \cdot \color{blue}{\left(-\frac{x}{z}\right)}} \]
    5. sqr-neg39.3%

      \[\leadsto y \cdot \sqrt{\color{blue}{\frac{x}{z} \cdot \frac{x}{z}}} \]
    6. sqrt-unprod22.0%

      \[\leadsto y \cdot \color{blue}{\left(\sqrt{\frac{x}{z}} \cdot \sqrt{\frac{x}{z}}\right)} \]
    7. add-sqr-sqrt29.9%

      \[\leadsto y \cdot \color{blue}{\frac{x}{z}} \]
    8. *-un-lft-identity29.9%

      \[\leadsto y \cdot \color{blue}{\left(1 \cdot \frac{x}{z}\right)} \]
  12. Applied egg-rr29.9%

    \[\leadsto y \cdot \color{blue}{\left(1 \cdot \frac{x}{z}\right)} \]
  13. Step-by-step derivation
    1. *-lft-identity29.9%

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

    \[\leadsto y \cdot \color{blue}{\frac{x}{z}} \]
  15. Final simplification29.9%

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

Developer Target 1: 96.7% 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 2024185 
(FPCore (x y z)
  :name "Statistics.Distribution.Beta:$cvariance from math-functions-0.1.5.2"
  :precision binary64

  :alt
  (! :herbie-platform default (if (< z 2496182814532307/10000000000000) (/ (* y (/ x z)) (+ z (* z z))) (/ (* (/ (/ y z) (+ 1 z)) x) z)))

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