Statistics.Distribution.CauchyLorentz:$cdensity from math-functions-0.1.5.2

Percentage Accurate: 89.3% → 99.4%
Time: 11.2s
Alternatives: 11
Speedup: 0.7×

Specification

?
\[\begin{array}{l} \\ \frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \end{array} \]
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
double code(double x, double y, double z) {
	return (1.0 / x) / (y * (1.0 + (z * z)));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
end function
public static double code(double x, double y, double z) {
	return (1.0 / x) / (y * (1.0 + (z * z)));
}
def code(x, y, z):
	return (1.0 / x) / (y * (1.0 + (z * z)))
function code(x, y, z)
	return Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z))))
end
function tmp = code(x, y, z)
	tmp = (1.0 / x) / (y * (1.0 + (z * z)));
end
code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\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 11 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: 89.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \end{array} \]
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
double code(double x, double y, double z) {
	return (1.0 / x) / (y * (1.0 + (z * z)));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
end function
public static double code(double x, double y, double z) {
	return (1.0 / x) / (y * (1.0 + (z * z)));
}
def code(x, y, z):
	return (1.0 / x) / (y * (1.0 + (z * z)))
function code(x, y, z)
	return Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z))))
end
function tmp = code(x, y, z)
	tmp = (1.0 / x) / (y * (1.0 + (z * z)));
end
code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 99.4% accurate, 0.1× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ 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_m] = \mathsf{sort}([x_m, y_m, z_m])\\ \\ y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;y\_m \cdot \left(1 + z\_m \cdot z\_m\right) \leq 1.2 \cdot 10^{+307}:\\ \;\;\;\;\frac{\frac{1}{x\_m}}{\mathsf{fma}\left(y\_m \cdot z\_m, z\_m, y\_m\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{\frac{1}{x\_m}}{\mathsf{hypot}\left(1, z\_m\right)}}{y\_m}}{z\_m}\\ \end{array}\right) \end{array} \]
z_m = (fabs.f64 z)
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_m should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z_m)
 :precision binary64
 (*
  y_s
  (*
   x_s
   (if (<= (* y_m (+ 1.0 (* z_m z_m))) 1.2e+307)
     (/ (/ 1.0 x_m) (fma (* y_m z_m) z_m y_m))
     (/ (/ (/ (/ 1.0 x_m) (hypot 1.0 z_m)) y_m) z_m)))))
z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if ((y_m * (1.0 + (z_m * z_m))) <= 1.2e+307) {
		tmp = (1.0 / x_m) / fma((y_m * z_m), z_m, y_m);
	} else {
		tmp = (((1.0 / x_m) / hypot(1.0, z_m)) / y_m) / z_m;
	}
	return y_s * (x_s * tmp);
}
z_m = abs(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_m = sort([x_m, y_m, z_m])
function code(y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0
	if (Float64(y_m * Float64(1.0 + Float64(z_m * z_m))) <= 1.2e+307)
		tmp = Float64(Float64(1.0 / x_m) / fma(Float64(y_m * z_m), z_m, y_m));
	else
		tmp = Float64(Float64(Float64(Float64(1.0 / x_m) / hypot(1.0, z_m)) / y_m) / z_m);
	end
	return Float64(y_s * Float64(x_s * tmp))
end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(x$95$s * If[LessEqual[N[(y$95$m * N[(1.0 + N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.2e+307], N[(N[(1.0 / x$95$m), $MachinePrecision] / N[(N[(y$95$m * z$95$m), $MachinePrecision] * z$95$m + y$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 / x$95$m), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z$95$m ^ 2], $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision] / z$95$m), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \cdot \left(1 + z\_m \cdot z\_m\right) \leq 1.2 \cdot 10^{+307}:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{\mathsf{fma}\left(y\_m \cdot z\_m, z\_m, y\_m\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\frac{1}{x\_m}}{\mathsf{hypot}\left(1, z\_m\right)}}{y\_m}}{z\_m}\\


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

    1. Initial program 95.9%

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{\mathsf{fma}\left(y \cdot z, z, y\right)}} \]
    4. Applied egg-rr97.2%

      \[\leadsto \frac{\frac{1}{x}}{\color{blue}{\mathsf{fma}\left(y \cdot z, z, y\right)}} \]

    if 1.20000000000000008e307 < (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z)))

    1. Initial program 91.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{y \cdot \color{blue}{\left(\sqrt{x \cdot \mathsf{fma}\left(z, z, 1\right)} \cdot \sqrt{x \cdot \mathsf{fma}\left(z, z, 1\right)}\right)}} \]
      2. pow257.6%

        \[\leadsto \frac{1}{y \cdot \color{blue}{{\left(\sqrt{x \cdot \mathsf{fma}\left(z, z, 1\right)}\right)}^{2}}} \]
      3. *-commutative57.6%

        \[\leadsto \frac{1}{y \cdot {\left(\sqrt{\color{blue}{\mathsf{fma}\left(z, z, 1\right) \cdot x}}\right)}^{2}} \]
      4. sqrt-prod57.6%

        \[\leadsto \frac{1}{y \cdot {\color{blue}{\left(\sqrt{\mathsf{fma}\left(z, z, 1\right)} \cdot \sqrt{x}\right)}}^{2}} \]
      5. fma-undefine57.6%

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

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

        \[\leadsto \frac{1}{y \cdot {\left(\color{blue}{\mathsf{hypot}\left(1, z\right)} \cdot \sqrt{x}\right)}^{2}} \]
    6. Applied egg-rr57.6%

      \[\leadsto \frac{1}{y \cdot \color{blue}{{\left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{x}\right)}^{2}}} \]
    7. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{y} \cdot \frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{x}} \]
    8. Taylor expanded in z around inf 93.9%

      \[\leadsto \color{blue}{\frac{1}{y \cdot z}} \cdot \frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{x} \]
    9. Step-by-step derivation
      1. associate-*l/93.9%

        \[\leadsto \color{blue}{\frac{1 \cdot \frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{x}}{y \cdot z}} \]
      2. *-un-lft-identity93.9%

        \[\leadsto \frac{\color{blue}{\frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{x}}}{y \cdot z} \]
      3. associate-/r*93.9%

        \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{x}}{y}}{z}} \]
      4. associate-/l/93.9%

        \[\leadsto \frac{\frac{\color{blue}{\frac{1}{x \cdot \mathsf{hypot}\left(1, z\right)}}}{y}}{z} \]
      5. associate-/r*93.9%

        \[\leadsto \frac{\frac{\color{blue}{\frac{\frac{1}{x}}{\mathsf{hypot}\left(1, z\right)}}}{y}}{z} \]
    10. Applied egg-rr93.9%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{1}{x}}{\mathsf{hypot}\left(1, z\right)}}{y}}{z}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.7%

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

Alternative 2: 97.9% accurate, 0.0× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ 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_m] = \mathsf{sort}([x_m, y_m, z_m])\\ \\ y\_s \cdot \left(x\_s \cdot \frac{1}{y\_m \cdot {\left(\mathsf{hypot}\left(1, z\_m\right) \cdot \sqrt{x\_m}\right)}^{2}}\right) \end{array} \]
z_m = (fabs.f64 z)
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_m should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z_m)
 :precision binary64
 (* y_s (* x_s (/ 1.0 (* y_m (pow (* (hypot 1.0 z_m) (sqrt x_m)) 2.0))))))
z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
	return y_s * (x_s * (1.0 / (y_m * pow((hypot(1.0, z_m) * sqrt(x_m)), 2.0))));
}
z_m = Math.abs(z);
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_m;
public static double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
	return y_s * (x_s * (1.0 / (y_m * Math.pow((Math.hypot(1.0, z_m) * Math.sqrt(x_m)), 2.0))));
}
z_m = math.fabs(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_m] = sort([x_m, y_m, z_m])
def code(y_s, x_s, x_m, y_m, z_m):
	return y_s * (x_s * (1.0 / (y_m * math.pow((math.hypot(1.0, z_m) * math.sqrt(x_m)), 2.0))))
z_m = abs(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_m = sort([x_m, y_m, z_m])
function code(y_s, x_s, x_m, y_m, z_m)
	return Float64(y_s * Float64(x_s * Float64(1.0 / Float64(y_m * (Float64(hypot(1.0, z_m) * sqrt(x_m)) ^ 2.0)))))
end
z_m = abs(z);
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_m = num2cell(sort([x_m, y_m, z_m])){:}
function tmp = code(y_s, x_s, x_m, y_m, z_m)
	tmp = y_s * (x_s * (1.0 / (y_m * ((hypot(1.0, z_m) * sqrt(x_m)) ^ 2.0))));
end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(x$95$s * N[(1.0 / N[(y$95$m * N[Power[N[(N[Sqrt[1.0 ^ 2 + z$95$m ^ 2], $MachinePrecision] * N[Sqrt[x$95$m], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
y\_s \cdot \left(x\_s \cdot \frac{1}{y\_m \cdot {\left(\mathsf{hypot}\left(1, z\_m\right) \cdot \sqrt{x\_m}\right)}^{2}}\right)
\end{array}
Derivation
  1. Initial program 95.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{y \cdot {\left(\color{blue}{\mathsf{hypot}\left(1, z\right)} \cdot \sqrt{x}\right)}^{2}} \]
  6. Applied egg-rr49.4%

    \[\leadsto \frac{1}{y \cdot \color{blue}{{\left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{x}\right)}^{2}}} \]
  7. Final simplification49.4%

    \[\leadsto \frac{1}{y \cdot {\left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{x}\right)}^{2}} \]
  8. Add Preprocessing

Alternative 3: 98.7% accurate, 0.1× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ 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_m] = \mathsf{sort}([x_m, y_m, z_m])\\ \\ y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;z\_m \cdot z\_m \leq 10^{+36}:\\ \;\;\;\;\frac{\frac{1}{x\_m}}{\mathsf{fma}\left(y\_m \cdot z\_m, z\_m, y\_m\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y\_m} \cdot \left(\frac{1}{z\_m} \cdot \frac{\frac{1}{z\_m}}{x\_m}\right)\\ \end{array}\right) \end{array} \]
z_m = (fabs.f64 z)
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_m should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z_m)
 :precision binary64
 (*
  y_s
  (*
   x_s
   (if (<= (* z_m z_m) 1e+36)
     (/ (/ 1.0 x_m) (fma (* y_m z_m) z_m y_m))
     (* (/ 1.0 y_m) (* (/ 1.0 z_m) (/ (/ 1.0 z_m) x_m)))))))
z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if ((z_m * z_m) <= 1e+36) {
		tmp = (1.0 / x_m) / fma((y_m * z_m), z_m, y_m);
	} else {
		tmp = (1.0 / y_m) * ((1.0 / z_m) * ((1.0 / z_m) / x_m));
	}
	return y_s * (x_s * tmp);
}
z_m = abs(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_m = sort([x_m, y_m, z_m])
function code(y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0
	if (Float64(z_m * z_m) <= 1e+36)
		tmp = Float64(Float64(1.0 / x_m) / fma(Float64(y_m * z_m), z_m, y_m));
	else
		tmp = Float64(Float64(1.0 / y_m) * Float64(Float64(1.0 / z_m) * Float64(Float64(1.0 / z_m) / x_m)));
	end
	return Float64(y_s * Float64(x_s * tmp))
end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(x$95$s * If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 1e+36], N[(N[(1.0 / x$95$m), $MachinePrecision] / N[(N[(y$95$m * z$95$m), $MachinePrecision] * z$95$m + y$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y$95$m), $MachinePrecision] * N[(N[(1.0 / z$95$m), $MachinePrecision] * N[(N[(1.0 / z$95$m), $MachinePrecision] / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \cdot z\_m \leq 10^{+36}:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{\mathsf{fma}\left(y\_m \cdot z\_m, z\_m, y\_m\right)}\\

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


\end{array}\right)
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z z) < 1.00000000000000004e36

    1. Initial program 99.7%

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{\mathsf{fma}\left(y \cdot z, z, y\right)}} \]
    4. Applied egg-rr99.7%

      \[\leadsto \frac{\frac{1}{x}}{\color{blue}{\mathsf{fma}\left(y \cdot z, z, y\right)}} \]

    if 1.00000000000000004e36 < (*.f64 z z)

    1. Initial program 88.8%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{y \cdot \left(x \cdot \mathsf{fma}\left(z, z, 1\right)\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 88.8%

      \[\leadsto \frac{1}{\color{blue}{x \cdot \left(y \cdot {z}^{2}\right)}} \]
    6. Step-by-step derivation
      1. *-commutative88.8%

        \[\leadsto \frac{1}{x \cdot \color{blue}{\left({z}^{2} \cdot y\right)}} \]
    7. Simplified88.8%

      \[\leadsto \frac{1}{\color{blue}{x \cdot \left({z}^{2} \cdot y\right)}} \]
    8. Step-by-step derivation
      1. inv-pow88.8%

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

        \[\leadsto {\color{blue}{\left(\left({z}^{2} \cdot y\right) \cdot x\right)}}^{-1} \]
      3. associate-*l*84.5%

        \[\leadsto {\color{blue}{\left({z}^{2} \cdot \left(y \cdot x\right)\right)}}^{-1} \]
      4. unpow284.5%

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

        \[\leadsto {\left(\left(z \cdot z\right) \cdot \color{blue}{\left(x \cdot y\right)}\right)}^{-1} \]
      6. add-sqr-sqrt43.7%

        \[\leadsto {\left(\left(z \cdot z\right) \cdot \color{blue}{\left(\sqrt{x \cdot y} \cdot \sqrt{x \cdot y}\right)}\right)}^{-1} \]
      7. swap-sqr48.2%

        \[\leadsto {\color{blue}{\left(\left(z \cdot \sqrt{x \cdot y}\right) \cdot \left(z \cdot \sqrt{x \cdot y}\right)\right)}}^{-1} \]
      8. pow-prod-down48.2%

        \[\leadsto \color{blue}{{\left(z \cdot \sqrt{x \cdot y}\right)}^{-1} \cdot {\left(z \cdot \sqrt{x \cdot y}\right)}^{-1}} \]
      9. pow-sqr48.2%

        \[\leadsto \color{blue}{{\left(z \cdot \sqrt{x \cdot y}\right)}^{\left(2 \cdot -1\right)}} \]
      10. *-commutative48.2%

        \[\leadsto {\color{blue}{\left(\sqrt{x \cdot y} \cdot z\right)}}^{\left(2 \cdot -1\right)} \]
      11. metadata-eval48.2%

        \[\leadsto {\left(\sqrt{x \cdot y} \cdot z\right)}^{\color{blue}{-2}} \]
      12. unpow-prod-down44.2%

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

        \[\leadsto \color{blue}{{\left(x \cdot y\right)}^{\left(\frac{-2}{2}\right)}} \cdot {z}^{-2} \]
      14. metadata-eval84.9%

        \[\leadsto {\left(x \cdot y\right)}^{\color{blue}{-1}} \cdot {z}^{-2} \]
      15. inv-pow84.9%

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{y}}{x}} \cdot {z}^{-2} \]
    9. Applied egg-rr84.9%

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

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

        \[\leadsto \color{blue}{\frac{1}{y} \cdot \frac{{z}^{-2}}{x}} \]
    11. Simplified86.9%

      \[\leadsto \color{blue}{\frac{1}{y} \cdot \frac{{z}^{-2}}{x}} \]
    12. Step-by-step derivation
      1. sqr-pow86.9%

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

        \[\leadsto \frac{1}{y} \cdot \color{blue}{\left({z}^{\left(\frac{-2}{2}\right)} \cdot \frac{{z}^{\left(\frac{-2}{2}\right)}}{x}\right)} \]
      3. metadata-eval93.8%

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

        \[\leadsto \frac{1}{y} \cdot \left(\color{blue}{\frac{1}{z}} \cdot \frac{{z}^{\left(\frac{-2}{2}\right)}}{x}\right) \]
      5. metadata-eval93.8%

        \[\leadsto \frac{1}{y} \cdot \left(\frac{1}{z} \cdot \frac{{z}^{\color{blue}{-1}}}{x}\right) \]
      6. unpow-193.8%

        \[\leadsto \frac{1}{y} \cdot \left(\frac{1}{z} \cdot \frac{\color{blue}{\frac{1}{z}}}{x}\right) \]
    13. Applied egg-rr93.8%

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

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

Alternative 4: 96.8% accurate, 0.5× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ 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_m] = \mathsf{sort}([x_m, y_m, z_m])\\ \\ \begin{array}{l} t_0 := y\_m \cdot \left(1 + z\_m \cdot z\_m\right)\\ y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq 1.2 \cdot 10^{+307}:\\ \;\;\;\;\frac{\frac{1}{x\_m}}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z\_m} \cdot \frac{\frac{1}{z\_m}}{y\_m \cdot x\_m}\\ \end{array}\right) \end{array} \end{array} \]
z_m = (fabs.f64 z)
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_m should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z_m)
 :precision binary64
 (let* ((t_0 (* y_m (+ 1.0 (* z_m z_m)))))
   (*
    y_s
    (*
     x_s
     (if (<= t_0 1.2e+307)
       (/ (/ 1.0 x_m) t_0)
       (* (/ 1.0 z_m) (/ (/ 1.0 z_m) (* y_m x_m))))))))
z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
	double t_0 = y_m * (1.0 + (z_m * z_m));
	double tmp;
	if (t_0 <= 1.2e+307) {
		tmp = (1.0 / x_m) / t_0;
	} else {
		tmp = (1.0 / z_m) * ((1.0 / z_m) / (y_m * x_m));
	}
	return y_s * (x_s * tmp);
}
z_m = abs(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_m should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z_m)
    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_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = y_m * (1.0d0 + (z_m * z_m))
    if (t_0 <= 1.2d+307) then
        tmp = (1.0d0 / x_m) / t_0
    else
        tmp = (1.0d0 / z_m) * ((1.0d0 / z_m) / (y_m * x_m))
    end if
    code = y_s * (x_s * tmp)
end function
z_m = Math.abs(z);
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_m;
public static double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
	double t_0 = y_m * (1.0 + (z_m * z_m));
	double tmp;
	if (t_0 <= 1.2e+307) {
		tmp = (1.0 / x_m) / t_0;
	} else {
		tmp = (1.0 / z_m) * ((1.0 / z_m) / (y_m * x_m));
	}
	return y_s * (x_s * tmp);
}
z_m = math.fabs(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_m] = sort([x_m, y_m, z_m])
def code(y_s, x_s, x_m, y_m, z_m):
	t_0 = y_m * (1.0 + (z_m * z_m))
	tmp = 0
	if t_0 <= 1.2e+307:
		tmp = (1.0 / x_m) / t_0
	else:
		tmp = (1.0 / z_m) * ((1.0 / z_m) / (y_m * x_m))
	return y_s * (x_s * tmp)
z_m = abs(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_m = sort([x_m, y_m, z_m])
function code(y_s, x_s, x_m, y_m, z_m)
	t_0 = Float64(y_m * Float64(1.0 + Float64(z_m * z_m)))
	tmp = 0.0
	if (t_0 <= 1.2e+307)
		tmp = Float64(Float64(1.0 / x_m) / t_0);
	else
		tmp = Float64(Float64(1.0 / z_m) * Float64(Float64(1.0 / z_m) / Float64(y_m * x_m)));
	end
	return Float64(y_s * Float64(x_s * tmp))
end
z_m = abs(z);
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_m = num2cell(sort([x_m, y_m, z_m])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z_m)
	t_0 = y_m * (1.0 + (z_m * z_m));
	tmp = 0.0;
	if (t_0 <= 1.2e+307)
		tmp = (1.0 / x_m) / t_0;
	else
		tmp = (1.0 / z_m) * ((1.0 / z_m) / (y_m * x_m));
	end
	tmp_2 = y_s * (x_s * tmp);
end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := Block[{t$95$0 = N[(y$95$m * N[(1.0 + N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * N[(x$95$s * If[LessEqual[t$95$0, 1.2e+307], N[(N[(1.0 / x$95$m), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(1.0 / z$95$m), $MachinePrecision] * N[(N[(1.0 / z$95$m), $MachinePrecision] / N[(y$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
\begin{array}{l}
t_0 := y\_m \cdot \left(1 + z\_m \cdot z\_m\right)\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 1.2 \cdot 10^{+307}:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{t\_0}\\

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


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

    1. Initial program 95.9%

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

    if 1.20000000000000008e307 < (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z)))

    1. Initial program 91.2%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{y \cdot \left(x \cdot \mathsf{fma}\left(z, z, 1\right)\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 88.4%

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{1}}{\sqrt{y \cdot \left(x \cdot {z}^{2}\right)}}} \cdot \sqrt{\frac{1}{y \cdot \left(x \cdot {z}^{2}\right)}} \]
      3. metadata-eval54.8%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{y \cdot \left(x \cdot {z}^{2}\right)}} \cdot \sqrt{\frac{1}{y \cdot \left(x \cdot {z}^{2}\right)}} \]
      4. associate-*r*57.6%

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

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

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

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

        \[\leadsto \frac{1}{\sqrt{y \cdot x} \cdot \color{blue}{{z}^{\left(\frac{2}{2}\right)}}} \cdot \sqrt{\frac{1}{y \cdot \left(x \cdot {z}^{2}\right)}} \]
      9. metadata-eval57.6%

        \[\leadsto \frac{1}{\sqrt{y \cdot x} \cdot {z}^{\color{blue}{1}}} \cdot \sqrt{\frac{1}{y \cdot \left(x \cdot {z}^{2}\right)}} \]
      10. pow157.6%

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

        \[\leadsto \frac{1}{\sqrt{y \cdot x} \cdot z} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{y \cdot \left(x \cdot {z}^{2}\right)}}} \]
      12. metadata-eval57.6%

        \[\leadsto \frac{1}{\sqrt{y \cdot x} \cdot z} \cdot \frac{\color{blue}{1}}{\sqrt{y \cdot \left(x \cdot {z}^{2}\right)}} \]
      13. associate-*r*57.6%

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

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

        \[\leadsto \frac{1}{\sqrt{y \cdot x} \cdot z} \cdot \frac{1}{\color{blue}{\sqrt{x \cdot y} \cdot \sqrt{{z}^{2}}}} \]
      16. *-commutative57.6%

        \[\leadsto \frac{1}{\sqrt{y \cdot x} \cdot z} \cdot \frac{1}{\sqrt{\color{blue}{y \cdot x}} \cdot \sqrt{{z}^{2}}} \]
      17. sqrt-pow160.6%

        \[\leadsto \frac{1}{\sqrt{y \cdot x} \cdot z} \cdot \frac{1}{\sqrt{y \cdot x} \cdot \color{blue}{{z}^{\left(\frac{2}{2}\right)}}} \]
      18. metadata-eval60.6%

        \[\leadsto \frac{1}{\sqrt{y \cdot x} \cdot z} \cdot \frac{1}{\sqrt{y \cdot x} \cdot {z}^{\color{blue}{1}}} \]
      19. pow160.6%

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

      \[\leadsto \color{blue}{\frac{1}{\sqrt{y \cdot x} \cdot z} \cdot \frac{1}{\sqrt{y \cdot x} \cdot z}} \]
    8. Step-by-step derivation
      1. unpow-160.6%

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

        \[\leadsto {\left(\sqrt{y \cdot x} \cdot z\right)}^{-1} \cdot \color{blue}{{\left(\sqrt{y \cdot x} \cdot z\right)}^{-1}} \]
      3. pow-sqr60.6%

        \[\leadsto \color{blue}{{\left(\sqrt{y \cdot x} \cdot z\right)}^{\left(2 \cdot -1\right)}} \]
      4. *-commutative60.6%

        \[\leadsto {\color{blue}{\left(z \cdot \sqrt{y \cdot x}\right)}}^{\left(2 \cdot -1\right)} \]
      5. *-commutative60.6%

        \[\leadsto {\left(z \cdot \sqrt{\color{blue}{x \cdot y}}\right)}^{\left(2 \cdot -1\right)} \]
      6. metadata-eval60.6%

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

      \[\leadsto \color{blue}{{\left(z \cdot \sqrt{x \cdot y}\right)}^{-2}} \]
    10. Step-by-step derivation
      1. metadata-eval60.6%

        \[\leadsto {\left(z \cdot \sqrt{x \cdot y}\right)}^{\color{blue}{\left(-1 + -1\right)}} \]
      2. pow-prod-up60.6%

        \[\leadsto \color{blue}{{\left(z \cdot \sqrt{x \cdot y}\right)}^{-1} \cdot {\left(z \cdot \sqrt{x \cdot y}\right)}^{-1}} \]
      3. pow-prod-down60.5%

        \[\leadsto \color{blue}{{\left(\left(z \cdot \sqrt{x \cdot y}\right) \cdot \left(z \cdot \sqrt{x \cdot y}\right)\right)}^{-1}} \]
      4. swap-sqr57.6%

        \[\leadsto {\color{blue}{\left(\left(z \cdot z\right) \cdot \left(\sqrt{x \cdot y} \cdot \sqrt{x \cdot y}\right)\right)}}^{-1} \]
      5. unpow257.6%

        \[\leadsto {\left(\color{blue}{{z}^{2}} \cdot \left(\sqrt{x \cdot y} \cdot \sqrt{x \cdot y}\right)\right)}^{-1} \]
      6. add-sqr-sqrt91.2%

        \[\leadsto {\left({z}^{2} \cdot \color{blue}{\left(x \cdot y\right)}\right)}^{-1} \]
      7. *-commutative91.2%

        \[\leadsto {\left({z}^{2} \cdot \color{blue}{\left(y \cdot x\right)}\right)}^{-1} \]
      8. associate-*l*88.4%

        \[\leadsto {\color{blue}{\left(\left({z}^{2} \cdot y\right) \cdot x\right)}}^{-1} \]
      9. *-commutative88.4%

        \[\leadsto {\color{blue}{\left(x \cdot \left({z}^{2} \cdot y\right)\right)}}^{-1} \]
      10. inv-pow88.4%

        \[\leadsto \color{blue}{\frac{1}{x \cdot \left({z}^{2} \cdot y\right)}} \]
      11. associate-*r*88.4%

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot {z}^{2}\right) \cdot y}} \]
      12. associate-/r*88.4%

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

      \[\leadsto \color{blue}{\frac{\frac{1}{x \cdot {z}^{2}}}{y}} \]
    12. Step-by-step derivation
      1. inv-pow88.4%

        \[\leadsto \frac{\color{blue}{{\left(x \cdot {z}^{2}\right)}^{-1}}}{y} \]
      2. unpow-prod-down88.4%

        \[\leadsto \frac{\color{blue}{{x}^{-1} \cdot {\left({z}^{2}\right)}^{-1}}}{y} \]
      3. inv-pow88.4%

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

        \[\leadsto \frac{\frac{1}{x} \cdot {\color{blue}{\left(z \cdot z\right)}}^{-1}}{y} \]
      5. pow-prod-down88.5%

        \[\leadsto \frac{\frac{1}{x} \cdot \color{blue}{\left({z}^{-1} \cdot {z}^{-1}\right)}}{y} \]
      6. pow-sqr88.5%

        \[\leadsto \frac{\frac{1}{x} \cdot \color{blue}{{z}^{\left(2 \cdot -1\right)}}}{y} \]
      7. metadata-eval88.5%

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

        \[\leadsto \frac{\color{blue}{{z}^{-2} \cdot \frac{1}{x}}}{y} \]
      9. div-inv88.5%

        \[\leadsto \frac{\color{blue}{\frac{{z}^{-2}}{x}}}{y} \]
      10. associate-/l/91.3%

        \[\leadsto \color{blue}{\frac{{z}^{-2}}{y \cdot x}} \]
      11. sqr-pow91.3%

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

        \[\leadsto \color{blue}{{z}^{\left(\frac{-2}{2}\right)} \cdot \frac{{z}^{\left(\frac{-2}{2}\right)}}{y \cdot x}} \]
      13. metadata-eval97.0%

        \[\leadsto {z}^{\color{blue}{-1}} \cdot \frac{{z}^{\left(\frac{-2}{2}\right)}}{y \cdot x} \]
      14. unpow-197.0%

        \[\leadsto \color{blue}{\frac{1}{z}} \cdot \frac{{z}^{\left(\frac{-2}{2}\right)}}{y \cdot x} \]
      15. metadata-eval97.0%

        \[\leadsto \frac{1}{z} \cdot \frac{{z}^{\color{blue}{-1}}}{y \cdot x} \]
      16. unpow-197.0%

        \[\leadsto \frac{1}{z} \cdot \frac{\color{blue}{\frac{1}{z}}}{y \cdot x} \]
      17. *-commutative97.0%

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

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

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

Alternative 5: 98.7% accurate, 0.5× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ 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_m] = \mathsf{sort}([x_m, y_m, z_m])\\ \\ y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;z\_m \cdot z\_m \leq 2 \cdot 10^{+28}:\\ \;\;\;\;\frac{\frac{1}{x\_m}}{y\_m \cdot \left(1 + z\_m \cdot z\_m\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y\_m} \cdot \left(\frac{1}{z\_m} \cdot \frac{\frac{1}{z\_m}}{x\_m}\right)\\ \end{array}\right) \end{array} \]
z_m = (fabs.f64 z)
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_m should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z_m)
 :precision binary64
 (*
  y_s
  (*
   x_s
   (if (<= (* z_m z_m) 2e+28)
     (/ (/ 1.0 x_m) (* y_m (+ 1.0 (* z_m z_m))))
     (* (/ 1.0 y_m) (* (/ 1.0 z_m) (/ (/ 1.0 z_m) x_m)))))))
z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if ((z_m * z_m) <= 2e+28) {
		tmp = (1.0 / x_m) / (y_m * (1.0 + (z_m * z_m)));
	} else {
		tmp = (1.0 / y_m) * ((1.0 / z_m) * ((1.0 / z_m) / x_m));
	}
	return y_s * (x_s * tmp);
}
z_m = abs(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_m should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z_m)
    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_m
    real(8) :: tmp
    if ((z_m * z_m) <= 2d+28) then
        tmp = (1.0d0 / x_m) / (y_m * (1.0d0 + (z_m * z_m)))
    else
        tmp = (1.0d0 / y_m) * ((1.0d0 / z_m) * ((1.0d0 / z_m) / x_m))
    end if
    code = y_s * (x_s * tmp)
end function
z_m = Math.abs(z);
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_m;
public static double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if ((z_m * z_m) <= 2e+28) {
		tmp = (1.0 / x_m) / (y_m * (1.0 + (z_m * z_m)));
	} else {
		tmp = (1.0 / y_m) * ((1.0 / z_m) * ((1.0 / z_m) / x_m));
	}
	return y_s * (x_s * tmp);
}
z_m = math.fabs(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_m] = sort([x_m, y_m, z_m])
def code(y_s, x_s, x_m, y_m, z_m):
	tmp = 0
	if (z_m * z_m) <= 2e+28:
		tmp = (1.0 / x_m) / (y_m * (1.0 + (z_m * z_m)))
	else:
		tmp = (1.0 / y_m) * ((1.0 / z_m) * ((1.0 / z_m) / x_m))
	return y_s * (x_s * tmp)
z_m = abs(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_m = sort([x_m, y_m, z_m])
function code(y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0
	if (Float64(z_m * z_m) <= 2e+28)
		tmp = Float64(Float64(1.0 / x_m) / Float64(y_m * Float64(1.0 + Float64(z_m * z_m))));
	else
		tmp = Float64(Float64(1.0 / y_m) * Float64(Float64(1.0 / z_m) * Float64(Float64(1.0 / z_m) / x_m)));
	end
	return Float64(y_s * Float64(x_s * tmp))
end
z_m = abs(z);
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_m = num2cell(sort([x_m, y_m, z_m])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0;
	if ((z_m * z_m) <= 2e+28)
		tmp = (1.0 / x_m) / (y_m * (1.0 + (z_m * z_m)));
	else
		tmp = (1.0 / y_m) * ((1.0 / z_m) * ((1.0 / z_m) / x_m));
	end
	tmp_2 = y_s * (x_s * tmp);
end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(x$95$s * If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 2e+28], N[(N[(1.0 / x$95$m), $MachinePrecision] / N[(y$95$m * N[(1.0 + N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y$95$m), $MachinePrecision] * N[(N[(1.0 / z$95$m), $MachinePrecision] * N[(N[(1.0 / z$95$m), $MachinePrecision] / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \cdot z\_m \leq 2 \cdot 10^{+28}:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y\_m \cdot \left(1 + z\_m \cdot z\_m\right)}\\

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


\end{array}\right)
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z z) < 1.99999999999999992e28

    1. Initial program 99.7%

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

    if 1.99999999999999992e28 < (*.f64 z z)

    1. Initial program 89.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{y \cdot \left(x \cdot \left(\color{blue}{z \cdot z} + 1\right)\right)} \]
      11. fma-define86.6%

        \[\leadsto \frac{1}{y \cdot \left(x \cdot \color{blue}{\mathsf{fma}\left(z, z, 1\right)}\right)} \]
    3. Simplified86.6%

      \[\leadsto \color{blue}{\frac{1}{y \cdot \left(x \cdot \mathsf{fma}\left(z, z, 1\right)\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 89.2%

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

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

      \[\leadsto \frac{1}{\color{blue}{x \cdot \left({z}^{2} \cdot y\right)}} \]
    8. Step-by-step derivation
      1. inv-pow89.2%

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

        \[\leadsto {\color{blue}{\left(\left({z}^{2} \cdot y\right) \cdot x\right)}}^{-1} \]
      3. associate-*l*85.0%

        \[\leadsto {\color{blue}{\left({z}^{2} \cdot \left(y \cdot x\right)\right)}}^{-1} \]
      4. unpow285.0%

        \[\leadsto {\left(\color{blue}{\left(z \cdot z\right)} \cdot \left(y \cdot x\right)\right)}^{-1} \]
      5. *-commutative85.0%

        \[\leadsto {\left(\left(z \cdot z\right) \cdot \color{blue}{\left(x \cdot y\right)}\right)}^{-1} \]
      6. add-sqr-sqrt43.0%

        \[\leadsto {\left(\left(z \cdot z\right) \cdot \color{blue}{\left(\sqrt{x \cdot y} \cdot \sqrt{x \cdot y}\right)}\right)}^{-1} \]
      7. swap-sqr47.3%

        \[\leadsto {\color{blue}{\left(\left(z \cdot \sqrt{x \cdot y}\right) \cdot \left(z \cdot \sqrt{x \cdot y}\right)\right)}}^{-1} \]
      8. pow-prod-down47.3%

        \[\leadsto \color{blue}{{\left(z \cdot \sqrt{x \cdot y}\right)}^{-1} \cdot {\left(z \cdot \sqrt{x \cdot y}\right)}^{-1}} \]
      9. pow-sqr47.4%

        \[\leadsto \color{blue}{{\left(z \cdot \sqrt{x \cdot y}\right)}^{\left(2 \cdot -1\right)}} \]
      10. *-commutative47.4%

        \[\leadsto {\color{blue}{\left(\sqrt{x \cdot y} \cdot z\right)}}^{\left(2 \cdot -1\right)} \]
      11. metadata-eval47.4%

        \[\leadsto {\left(\sqrt{x \cdot y} \cdot z\right)}^{\color{blue}{-2}} \]
      12. unpow-prod-down43.5%

        \[\leadsto \color{blue}{{\left(\sqrt{x \cdot y}\right)}^{-2} \cdot {z}^{-2}} \]
      13. sqrt-pow285.5%

        \[\leadsto \color{blue}{{\left(x \cdot y\right)}^{\left(\frac{-2}{2}\right)}} \cdot {z}^{-2} \]
      14. metadata-eval85.5%

        \[\leadsto {\left(x \cdot y\right)}^{\color{blue}{-1}} \cdot {z}^{-2} \]
      15. inv-pow85.5%

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{y}}{x}} \cdot {z}^{-2} \]
    9. Applied egg-rr85.5%

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

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

        \[\leadsto \color{blue}{\frac{1}{y} \cdot \frac{{z}^{-2}}{x}} \]
    11. Simplified87.4%

      \[\leadsto \color{blue}{\frac{1}{y} \cdot \frac{{z}^{-2}}{x}} \]
    12. Step-by-step derivation
      1. sqr-pow87.4%

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

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

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

        \[\leadsto \frac{1}{y} \cdot \left(\color{blue}{\frac{1}{z}} \cdot \frac{{z}^{\left(\frac{-2}{2}\right)}}{x}\right) \]
      5. metadata-eval94.1%

        \[\leadsto \frac{1}{y} \cdot \left(\frac{1}{z} \cdot \frac{{z}^{\color{blue}{-1}}}{x}\right) \]
      6. unpow-194.1%

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

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

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

Alternative 6: 94.5% accurate, 0.7× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ 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_m] = \mathsf{sort}([x_m, y_m, z_m])\\ \\ y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;z\_m \leq 1:\\ \;\;\;\;\frac{\frac{1}{x\_m}}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z\_m} \cdot \frac{\frac{1}{z\_m}}{y\_m \cdot x\_m}\\ \end{array}\right) \end{array} \]
z_m = (fabs.f64 z)
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_m should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z_m)
 :precision binary64
 (*
  y_s
  (*
   x_s
   (if (<= z_m 1.0)
     (/ (/ 1.0 x_m) y_m)
     (* (/ 1.0 z_m) (/ (/ 1.0 z_m) (* y_m x_m)))))))
z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if (z_m <= 1.0) {
		tmp = (1.0 / x_m) / y_m;
	} else {
		tmp = (1.0 / z_m) * ((1.0 / z_m) / (y_m * x_m));
	}
	return y_s * (x_s * tmp);
}
z_m = abs(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_m should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z_m)
    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_m
    real(8) :: tmp
    if (z_m <= 1.0d0) then
        tmp = (1.0d0 / x_m) / y_m
    else
        tmp = (1.0d0 / z_m) * ((1.0d0 / z_m) / (y_m * x_m))
    end if
    code = y_s * (x_s * tmp)
end function
z_m = Math.abs(z);
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_m;
public static double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if (z_m <= 1.0) {
		tmp = (1.0 / x_m) / y_m;
	} else {
		tmp = (1.0 / z_m) * ((1.0 / z_m) / (y_m * x_m));
	}
	return y_s * (x_s * tmp);
}
z_m = math.fabs(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_m] = sort([x_m, y_m, z_m])
def code(y_s, x_s, x_m, y_m, z_m):
	tmp = 0
	if z_m <= 1.0:
		tmp = (1.0 / x_m) / y_m
	else:
		tmp = (1.0 / z_m) * ((1.0 / z_m) / (y_m * x_m))
	return y_s * (x_s * tmp)
z_m = abs(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_m = sort([x_m, y_m, z_m])
function code(y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0
	if (z_m <= 1.0)
		tmp = Float64(Float64(1.0 / x_m) / y_m);
	else
		tmp = Float64(Float64(1.0 / z_m) * Float64(Float64(1.0 / z_m) / Float64(y_m * x_m)));
	end
	return Float64(y_s * Float64(x_s * tmp))
end
z_m = abs(z);
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_m = num2cell(sort([x_m, y_m, z_m])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0;
	if (z_m <= 1.0)
		tmp = (1.0 / x_m) / y_m;
	else
		tmp = (1.0 / z_m) * ((1.0 / z_m) / (y_m * x_m));
	end
	tmp_2 = y_s * (x_s * tmp);
end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(x$95$s * If[LessEqual[z$95$m, 1.0], N[(N[(1.0 / x$95$m), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(1.0 / z$95$m), $MachinePrecision] * N[(N[(1.0 / z$95$m), $MachinePrecision] / N[(y$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 1:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y\_m}\\

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


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

    1. Initial program 96.4%

      \[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 77.4%

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

    if 1 < z

    1. Initial program 91.5%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{y \cdot \left(x \cdot \mathsf{fma}\left(z, z, 1\right)\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 87.1%

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{1}}{\sqrt{y \cdot \left(x \cdot {z}^{2}\right)}}} \cdot \sqrt{\frac{1}{y \cdot \left(x \cdot {z}^{2}\right)}} \]
      3. metadata-eval43.4%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{y \cdot \left(x \cdot {z}^{2}\right)}} \cdot \sqrt{\frac{1}{y \cdot \left(x \cdot {z}^{2}\right)}} \]
      4. associate-*r*43.2%

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

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

        \[\leadsto \frac{1}{\color{blue}{\sqrt{x \cdot y} \cdot \sqrt{{z}^{2}}}} \cdot \sqrt{\frac{1}{y \cdot \left(x \cdot {z}^{2}\right)}} \]
      7. *-commutative43.3%

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

        \[\leadsto \frac{1}{\sqrt{y \cdot x} \cdot \color{blue}{{z}^{\left(\frac{2}{2}\right)}}} \cdot \sqrt{\frac{1}{y \cdot \left(x \cdot {z}^{2}\right)}} \]
      9. metadata-eval43.3%

        \[\leadsto \frac{1}{\sqrt{y \cdot x} \cdot {z}^{\color{blue}{1}}} \cdot \sqrt{\frac{1}{y \cdot \left(x \cdot {z}^{2}\right)}} \]
      10. pow143.3%

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

        \[\leadsto \frac{1}{\sqrt{y \cdot x} \cdot z} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{y \cdot \left(x \cdot {z}^{2}\right)}}} \]
      12. metadata-eval43.3%

        \[\leadsto \frac{1}{\sqrt{y \cdot x} \cdot z} \cdot \frac{\color{blue}{1}}{\sqrt{y \cdot \left(x \cdot {z}^{2}\right)}} \]
      13. associate-*r*46.6%

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

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

        \[\leadsto \frac{1}{\sqrt{y \cdot x} \cdot z} \cdot \frac{1}{\color{blue}{\sqrt{x \cdot y} \cdot \sqrt{{z}^{2}}}} \]
      16. *-commutative46.6%

        \[\leadsto \frac{1}{\sqrt{y \cdot x} \cdot z} \cdot \frac{1}{\sqrt{\color{blue}{y \cdot x}} \cdot \sqrt{{z}^{2}}} \]
      17. sqrt-pow151.5%

        \[\leadsto \frac{1}{\sqrt{y \cdot x} \cdot z} \cdot \frac{1}{\sqrt{y \cdot x} \cdot \color{blue}{{z}^{\left(\frac{2}{2}\right)}}} \]
      18. metadata-eval51.5%

        \[\leadsto \frac{1}{\sqrt{y \cdot x} \cdot z} \cdot \frac{1}{\sqrt{y \cdot x} \cdot {z}^{\color{blue}{1}}} \]
      19. pow151.5%

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

      \[\leadsto \color{blue}{\frac{1}{\sqrt{y \cdot x} \cdot z} \cdot \frac{1}{\sqrt{y \cdot x} \cdot z}} \]
    8. Step-by-step derivation
      1. unpow-151.5%

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

        \[\leadsto {\left(\sqrt{y \cdot x} \cdot z\right)}^{-1} \cdot \color{blue}{{\left(\sqrt{y \cdot x} \cdot z\right)}^{-1}} \]
      3. pow-sqr51.5%

        \[\leadsto \color{blue}{{\left(\sqrt{y \cdot x} \cdot z\right)}^{\left(2 \cdot -1\right)}} \]
      4. *-commutative51.5%

        \[\leadsto {\color{blue}{\left(z \cdot \sqrt{y \cdot x}\right)}}^{\left(2 \cdot -1\right)} \]
      5. *-commutative51.5%

        \[\leadsto {\left(z \cdot \sqrt{\color{blue}{x \cdot y}}\right)}^{\left(2 \cdot -1\right)} \]
      6. metadata-eval51.5%

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

      \[\leadsto \color{blue}{{\left(z \cdot \sqrt{x \cdot y}\right)}^{-2}} \]
    10. Step-by-step derivation
      1. metadata-eval51.5%

        \[\leadsto {\left(z \cdot \sqrt{x \cdot y}\right)}^{\color{blue}{\left(-1 + -1\right)}} \]
      2. pow-prod-up51.5%

        \[\leadsto \color{blue}{{\left(z \cdot \sqrt{x \cdot y}\right)}^{-1} \cdot {\left(z \cdot \sqrt{x \cdot y}\right)}^{-1}} \]
      3. pow-prod-down51.5%

        \[\leadsto \color{blue}{{\left(\left(z \cdot \sqrt{x \cdot y}\right) \cdot \left(z \cdot \sqrt{x \cdot y}\right)\right)}^{-1}} \]
      4. swap-sqr46.5%

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

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

        \[\leadsto {\left({z}^{2} \cdot \color{blue}{\left(x \cdot y\right)}\right)}^{-1} \]
      7. *-commutative88.7%

        \[\leadsto {\left({z}^{2} \cdot \color{blue}{\left(y \cdot x\right)}\right)}^{-1} \]
      8. associate-*l*90.5%

        \[\leadsto {\color{blue}{\left(\left({z}^{2} \cdot y\right) \cdot x\right)}}^{-1} \]
      9. *-commutative90.5%

        \[\leadsto {\color{blue}{\left(x \cdot \left({z}^{2} \cdot y\right)\right)}}^{-1} \]
      10. inv-pow90.5%

        \[\leadsto \color{blue}{\frac{1}{x \cdot \left({z}^{2} \cdot y\right)}} \]
      11. associate-*r*87.1%

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

        \[\leadsto \color{blue}{\frac{\frac{1}{x \cdot {z}^{2}}}{y}} \]
    11. Applied egg-rr87.2%

      \[\leadsto \color{blue}{\frac{\frac{1}{x \cdot {z}^{2}}}{y}} \]
    12. Step-by-step derivation
      1. inv-pow87.2%

        \[\leadsto \frac{\color{blue}{{\left(x \cdot {z}^{2}\right)}^{-1}}}{y} \]
      2. unpow-prod-down87.2%

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

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

        \[\leadsto \frac{\frac{1}{x} \cdot {\color{blue}{\left(z \cdot z\right)}}^{-1}}{y} \]
      5. pow-prod-down88.6%

        \[\leadsto \frac{\frac{1}{x} \cdot \color{blue}{\left({z}^{-1} \cdot {z}^{-1}\right)}}{y} \]
      6. pow-sqr88.5%

        \[\leadsto \frac{\frac{1}{x} \cdot \color{blue}{{z}^{\left(2 \cdot -1\right)}}}{y} \]
      7. metadata-eval88.5%

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

        \[\leadsto \frac{\color{blue}{{z}^{-2} \cdot \frac{1}{x}}}{y} \]
      9. div-inv88.6%

        \[\leadsto \frac{\color{blue}{\frac{{z}^{-2}}{x}}}{y} \]
      10. associate-/l/90.1%

        \[\leadsto \color{blue}{\frac{{z}^{-2}}{y \cdot x}} \]
      11. sqr-pow90.0%

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

        \[\leadsto \color{blue}{{z}^{\left(\frac{-2}{2}\right)} \cdot \frac{{z}^{\left(\frac{-2}{2}\right)}}{y \cdot x}} \]
      13. metadata-eval95.3%

        \[\leadsto {z}^{\color{blue}{-1}} \cdot \frac{{z}^{\left(\frac{-2}{2}\right)}}{y \cdot x} \]
      14. unpow-195.3%

        \[\leadsto \color{blue}{\frac{1}{z}} \cdot \frac{{z}^{\left(\frac{-2}{2}\right)}}{y \cdot x} \]
      15. metadata-eval95.3%

        \[\leadsto \frac{1}{z} \cdot \frac{{z}^{\color{blue}{-1}}}{y \cdot x} \]
      16. unpow-195.3%

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

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

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

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

Alternative 7: 97.3% accurate, 0.7× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ 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_m] = \mathsf{sort}([x_m, y_m, z_m])\\ \\ y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;z\_m \leq 1:\\ \;\;\;\;\frac{\frac{1}{x\_m}}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y\_m \cdot z\_m} \cdot \frac{1}{z\_m \cdot x\_m}\\ \end{array}\right) \end{array} \]
z_m = (fabs.f64 z)
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_m should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z_m)
 :precision binary64
 (*
  y_s
  (*
   x_s
   (if (<= z_m 1.0)
     (/ (/ 1.0 x_m) y_m)
     (* (/ 1.0 (* y_m z_m)) (/ 1.0 (* z_m x_m)))))))
z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if (z_m <= 1.0) {
		tmp = (1.0 / x_m) / y_m;
	} else {
		tmp = (1.0 / (y_m * z_m)) * (1.0 / (z_m * x_m));
	}
	return y_s * (x_s * tmp);
}
z_m = abs(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_m should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z_m)
    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_m
    real(8) :: tmp
    if (z_m <= 1.0d0) then
        tmp = (1.0d0 / x_m) / y_m
    else
        tmp = (1.0d0 / (y_m * z_m)) * (1.0d0 / (z_m * x_m))
    end if
    code = y_s * (x_s * tmp)
end function
z_m = Math.abs(z);
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_m;
public static double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if (z_m <= 1.0) {
		tmp = (1.0 / x_m) / y_m;
	} else {
		tmp = (1.0 / (y_m * z_m)) * (1.0 / (z_m * x_m));
	}
	return y_s * (x_s * tmp);
}
z_m = math.fabs(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_m] = sort([x_m, y_m, z_m])
def code(y_s, x_s, x_m, y_m, z_m):
	tmp = 0
	if z_m <= 1.0:
		tmp = (1.0 / x_m) / y_m
	else:
		tmp = (1.0 / (y_m * z_m)) * (1.0 / (z_m * x_m))
	return y_s * (x_s * tmp)
z_m = abs(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_m = sort([x_m, y_m, z_m])
function code(y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0
	if (z_m <= 1.0)
		tmp = Float64(Float64(1.0 / x_m) / y_m);
	else
		tmp = Float64(Float64(1.0 / Float64(y_m * z_m)) * Float64(1.0 / Float64(z_m * x_m)));
	end
	return Float64(y_s * Float64(x_s * tmp))
end
z_m = abs(z);
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_m = num2cell(sort([x_m, y_m, z_m])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0;
	if (z_m <= 1.0)
		tmp = (1.0 / x_m) / y_m;
	else
		tmp = (1.0 / (y_m * z_m)) * (1.0 / (z_m * x_m));
	end
	tmp_2 = y_s * (x_s * tmp);
end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(x$95$s * If[LessEqual[z$95$m, 1.0], N[(N[(1.0 / x$95$m), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(1.0 / N[(y$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(z$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 1:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y\_m}\\

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


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

    1. Initial program 96.4%

      \[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 77.4%

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

    if 1 < z

    1. Initial program 91.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{y \cdot \color{blue}{\left(\sqrt{x \cdot \mathsf{fma}\left(z, z, 1\right)} \cdot \sqrt{x \cdot \mathsf{fma}\left(z, z, 1\right)}\right)}} \]
      2. pow238.7%

        \[\leadsto \frac{1}{y \cdot \color{blue}{{\left(\sqrt{x \cdot \mathsf{fma}\left(z, z, 1\right)}\right)}^{2}}} \]
      3. *-commutative38.7%

        \[\leadsto \frac{1}{y \cdot {\left(\sqrt{\color{blue}{\mathsf{fma}\left(z, z, 1\right) \cdot x}}\right)}^{2}} \]
      4. sqrt-prod38.7%

        \[\leadsto \frac{1}{y \cdot {\color{blue}{\left(\sqrt{\mathsf{fma}\left(z, z, 1\right)} \cdot \sqrt{x}\right)}}^{2}} \]
      5. fma-undefine38.7%

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

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

        \[\leadsto \frac{1}{y \cdot {\left(\color{blue}{\mathsf{hypot}\left(1, z\right)} \cdot \sqrt{x}\right)}^{2}} \]
    6. Applied egg-rr38.7%

      \[\leadsto \frac{1}{y \cdot \color{blue}{{\left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{x}\right)}^{2}}} \]
    7. Applied egg-rr94.8%

      \[\leadsto \color{blue}{\frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{y} \cdot \frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{x}} \]
    8. Taylor expanded in z around inf 93.9%

      \[\leadsto \color{blue}{\frac{1}{y \cdot z}} \cdot \frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{x} \]
    9. Taylor expanded in z around inf 93.8%

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

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

Alternative 8: 97.3% accurate, 0.7× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ 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_m] = \mathsf{sort}([x_m, y_m, z_m])\\ \\ y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;z\_m \leq 1:\\ \;\;\;\;\frac{\frac{1}{x\_m}}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y\_m \cdot z\_m} \cdot \frac{\frac{1}{x\_m}}{z\_m}\\ \end{array}\right) \end{array} \]
z_m = (fabs.f64 z)
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_m should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z_m)
 :precision binary64
 (*
  y_s
  (*
   x_s
   (if (<= z_m 1.0)
     (/ (/ 1.0 x_m) y_m)
     (* (/ 1.0 (* y_m z_m)) (/ (/ 1.0 x_m) z_m))))))
z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if (z_m <= 1.0) {
		tmp = (1.0 / x_m) / y_m;
	} else {
		tmp = (1.0 / (y_m * z_m)) * ((1.0 / x_m) / z_m);
	}
	return y_s * (x_s * tmp);
}
z_m = abs(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_m should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z_m)
    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_m
    real(8) :: tmp
    if (z_m <= 1.0d0) then
        tmp = (1.0d0 / x_m) / y_m
    else
        tmp = (1.0d0 / (y_m * z_m)) * ((1.0d0 / x_m) / z_m)
    end if
    code = y_s * (x_s * tmp)
end function
z_m = Math.abs(z);
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_m;
public static double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if (z_m <= 1.0) {
		tmp = (1.0 / x_m) / y_m;
	} else {
		tmp = (1.0 / (y_m * z_m)) * ((1.0 / x_m) / z_m);
	}
	return y_s * (x_s * tmp);
}
z_m = math.fabs(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_m] = sort([x_m, y_m, z_m])
def code(y_s, x_s, x_m, y_m, z_m):
	tmp = 0
	if z_m <= 1.0:
		tmp = (1.0 / x_m) / y_m
	else:
		tmp = (1.0 / (y_m * z_m)) * ((1.0 / x_m) / z_m)
	return y_s * (x_s * tmp)
z_m = abs(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_m = sort([x_m, y_m, z_m])
function code(y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0
	if (z_m <= 1.0)
		tmp = Float64(Float64(1.0 / x_m) / y_m);
	else
		tmp = Float64(Float64(1.0 / Float64(y_m * z_m)) * Float64(Float64(1.0 / x_m) / z_m));
	end
	return Float64(y_s * Float64(x_s * tmp))
end
z_m = abs(z);
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_m = num2cell(sort([x_m, y_m, z_m])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0;
	if (z_m <= 1.0)
		tmp = (1.0 / x_m) / y_m;
	else
		tmp = (1.0 / (y_m * z_m)) * ((1.0 / x_m) / z_m);
	end
	tmp_2 = y_s * (x_s * tmp);
end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(x$95$s * If[LessEqual[z$95$m, 1.0], N[(N[(1.0 / x$95$m), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(1.0 / N[(y$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / x$95$m), $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 1:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y\_m}\\

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


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

    1. Initial program 96.4%

      \[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 77.4%

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

    if 1 < z

    1. Initial program 91.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{y \cdot \color{blue}{\left(\sqrt{x \cdot \mathsf{fma}\left(z, z, 1\right)} \cdot \sqrt{x \cdot \mathsf{fma}\left(z, z, 1\right)}\right)}} \]
      2. pow238.7%

        \[\leadsto \frac{1}{y \cdot \color{blue}{{\left(\sqrt{x \cdot \mathsf{fma}\left(z, z, 1\right)}\right)}^{2}}} \]
      3. *-commutative38.7%

        \[\leadsto \frac{1}{y \cdot {\left(\sqrt{\color{blue}{\mathsf{fma}\left(z, z, 1\right) \cdot x}}\right)}^{2}} \]
      4. sqrt-prod38.7%

        \[\leadsto \frac{1}{y \cdot {\color{blue}{\left(\sqrt{\mathsf{fma}\left(z, z, 1\right)} \cdot \sqrt{x}\right)}}^{2}} \]
      5. fma-undefine38.7%

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

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

        \[\leadsto \frac{1}{y \cdot {\left(\color{blue}{\mathsf{hypot}\left(1, z\right)} \cdot \sqrt{x}\right)}^{2}} \]
    6. Applied egg-rr38.7%

      \[\leadsto \frac{1}{y \cdot \color{blue}{{\left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{x}\right)}^{2}}} \]
    7. Applied egg-rr94.8%

      \[\leadsto \color{blue}{\frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{y} \cdot \frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{x}} \]
    8. Taylor expanded in z around inf 93.9%

      \[\leadsto \color{blue}{\frac{1}{y \cdot z}} \cdot \frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{x} \]
    9. Taylor expanded in z around inf 93.8%

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

        \[\leadsto \frac{1}{y \cdot z} \cdot \color{blue}{\frac{\frac{1}{x}}{z}} \]
    11. Simplified93.7%

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

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

Alternative 9: 97.3% accurate, 0.7× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ 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_m] = \mathsf{sort}([x_m, y_m, z_m])\\ \\ y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;z\_m \leq 1:\\ \;\;\;\;\frac{\frac{1}{x\_m}}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{z\_m}}{x\_m} \cdot \frac{1}{y\_m \cdot z\_m}\\ \end{array}\right) \end{array} \]
z_m = (fabs.f64 z)
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_m should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z_m)
 :precision binary64
 (*
  y_s
  (*
   x_s
   (if (<= z_m 1.0)
     (/ (/ 1.0 x_m) y_m)
     (* (/ (/ 1.0 z_m) x_m) (/ 1.0 (* y_m z_m)))))))
z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if (z_m <= 1.0) {
		tmp = (1.0 / x_m) / y_m;
	} else {
		tmp = ((1.0 / z_m) / x_m) * (1.0 / (y_m * z_m));
	}
	return y_s * (x_s * tmp);
}
z_m = abs(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_m should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z_m)
    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_m
    real(8) :: tmp
    if (z_m <= 1.0d0) then
        tmp = (1.0d0 / x_m) / y_m
    else
        tmp = ((1.0d0 / z_m) / x_m) * (1.0d0 / (y_m * z_m))
    end if
    code = y_s * (x_s * tmp)
end function
z_m = Math.abs(z);
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_m;
public static double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if (z_m <= 1.0) {
		tmp = (1.0 / x_m) / y_m;
	} else {
		tmp = ((1.0 / z_m) / x_m) * (1.0 / (y_m * z_m));
	}
	return y_s * (x_s * tmp);
}
z_m = math.fabs(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_m] = sort([x_m, y_m, z_m])
def code(y_s, x_s, x_m, y_m, z_m):
	tmp = 0
	if z_m <= 1.0:
		tmp = (1.0 / x_m) / y_m
	else:
		tmp = ((1.0 / z_m) / x_m) * (1.0 / (y_m * z_m))
	return y_s * (x_s * tmp)
z_m = abs(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_m = sort([x_m, y_m, z_m])
function code(y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0
	if (z_m <= 1.0)
		tmp = Float64(Float64(1.0 / x_m) / y_m);
	else
		tmp = Float64(Float64(Float64(1.0 / z_m) / x_m) * Float64(1.0 / Float64(y_m * z_m)));
	end
	return Float64(y_s * Float64(x_s * tmp))
end
z_m = abs(z);
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_m = num2cell(sort([x_m, y_m, z_m])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0;
	if (z_m <= 1.0)
		tmp = (1.0 / x_m) / y_m;
	else
		tmp = ((1.0 / z_m) / x_m) * (1.0 / (y_m * z_m));
	end
	tmp_2 = y_s * (x_s * tmp);
end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(x$95$s * If[LessEqual[z$95$m, 1.0], N[(N[(1.0 / x$95$m), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(N[(1.0 / z$95$m), $MachinePrecision] / x$95$m), $MachinePrecision] * N[(1.0 / N[(y$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 1:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y\_m}\\

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


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

    1. Initial program 96.4%

      \[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 77.4%

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

    if 1 < z

    1. Initial program 91.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{y \cdot \color{blue}{\left(\sqrt{x \cdot \mathsf{fma}\left(z, z, 1\right)} \cdot \sqrt{x \cdot \mathsf{fma}\left(z, z, 1\right)}\right)}} \]
      2. pow238.7%

        \[\leadsto \frac{1}{y \cdot \color{blue}{{\left(\sqrt{x \cdot \mathsf{fma}\left(z, z, 1\right)}\right)}^{2}}} \]
      3. *-commutative38.7%

        \[\leadsto \frac{1}{y \cdot {\left(\sqrt{\color{blue}{\mathsf{fma}\left(z, z, 1\right) \cdot x}}\right)}^{2}} \]
      4. sqrt-prod38.7%

        \[\leadsto \frac{1}{y \cdot {\color{blue}{\left(\sqrt{\mathsf{fma}\left(z, z, 1\right)} \cdot \sqrt{x}\right)}}^{2}} \]
      5. fma-undefine38.7%

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

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

        \[\leadsto \frac{1}{y \cdot {\left(\color{blue}{\mathsf{hypot}\left(1, z\right)} \cdot \sqrt{x}\right)}^{2}} \]
    6. Applied egg-rr38.7%

      \[\leadsto \frac{1}{y \cdot \color{blue}{{\left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{x}\right)}^{2}}} \]
    7. Applied egg-rr94.8%

      \[\leadsto \color{blue}{\frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{y} \cdot \frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{x}} \]
    8. Taylor expanded in z around inf 93.9%

      \[\leadsto \color{blue}{\frac{1}{y \cdot z}} \cdot \frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{x} \]
    9. Taylor expanded in z around inf 93.8%

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

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

Alternative 10: 73.3% accurate, 0.9× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ 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_m] = \mathsf{sort}([x_m, y_m, z_m])\\ \\ y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;z\_m \leq 1:\\ \;\;\;\;\frac{\frac{1}{x\_m}}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x\_m \cdot \left(y\_m \cdot z\_m\right)}\\ \end{array}\right) \end{array} \]
z_m = (fabs.f64 z)
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_m should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z_m)
 :precision binary64
 (*
  y_s
  (* x_s (if (<= z_m 1.0) (/ (/ 1.0 x_m) y_m) (/ 1.0 (* x_m (* y_m z_m)))))))
z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if (z_m <= 1.0) {
		tmp = (1.0 / x_m) / y_m;
	} else {
		tmp = 1.0 / (x_m * (y_m * z_m));
	}
	return y_s * (x_s * tmp);
}
z_m = abs(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_m should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z_m)
    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_m
    real(8) :: tmp
    if (z_m <= 1.0d0) then
        tmp = (1.0d0 / x_m) / y_m
    else
        tmp = 1.0d0 / (x_m * (y_m * z_m))
    end if
    code = y_s * (x_s * tmp)
end function
z_m = Math.abs(z);
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_m;
public static double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if (z_m <= 1.0) {
		tmp = (1.0 / x_m) / y_m;
	} else {
		tmp = 1.0 / (x_m * (y_m * z_m));
	}
	return y_s * (x_s * tmp);
}
z_m = math.fabs(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_m] = sort([x_m, y_m, z_m])
def code(y_s, x_s, x_m, y_m, z_m):
	tmp = 0
	if z_m <= 1.0:
		tmp = (1.0 / x_m) / y_m
	else:
		tmp = 1.0 / (x_m * (y_m * z_m))
	return y_s * (x_s * tmp)
z_m = abs(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_m = sort([x_m, y_m, z_m])
function code(y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0
	if (z_m <= 1.0)
		tmp = Float64(Float64(1.0 / x_m) / y_m);
	else
		tmp = Float64(1.0 / Float64(x_m * Float64(y_m * z_m)));
	end
	return Float64(y_s * Float64(x_s * tmp))
end
z_m = abs(z);
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_m = num2cell(sort([x_m, y_m, z_m])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0;
	if (z_m <= 1.0)
		tmp = (1.0 / x_m) / y_m;
	else
		tmp = 1.0 / (x_m * (y_m * z_m));
	end
	tmp_2 = y_s * (x_s * tmp);
end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(x$95$s * If[LessEqual[z$95$m, 1.0], N[(N[(1.0 / x$95$m), $MachinePrecision] / y$95$m), $MachinePrecision], N[(1.0 / N[(x$95$m * N[(y$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 1:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y\_m}\\

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


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

    1. Initial program 96.4%

      \[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 77.4%

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

    if 1 < z

    1. Initial program 91.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{y \cdot \color{blue}{\left(\sqrt{x \cdot \mathsf{fma}\left(z, z, 1\right)} \cdot \sqrt{x \cdot \mathsf{fma}\left(z, z, 1\right)}\right)}} \]
      2. pow238.7%

        \[\leadsto \frac{1}{y \cdot \color{blue}{{\left(\sqrt{x \cdot \mathsf{fma}\left(z, z, 1\right)}\right)}^{2}}} \]
      3. *-commutative38.7%

        \[\leadsto \frac{1}{y \cdot {\left(\sqrt{\color{blue}{\mathsf{fma}\left(z, z, 1\right) \cdot x}}\right)}^{2}} \]
      4. sqrt-prod38.7%

        \[\leadsto \frac{1}{y \cdot {\color{blue}{\left(\sqrt{\mathsf{fma}\left(z, z, 1\right)} \cdot \sqrt{x}\right)}}^{2}} \]
      5. fma-undefine38.7%

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

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

        \[\leadsto \frac{1}{y \cdot {\left(\color{blue}{\mathsf{hypot}\left(1, z\right)} \cdot \sqrt{x}\right)}^{2}} \]
    6. Applied egg-rr38.7%

      \[\leadsto \frac{1}{y \cdot \color{blue}{{\left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{x}\right)}^{2}}} \]
    7. Applied egg-rr94.8%

      \[\leadsto \color{blue}{\frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{y} \cdot \frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{x}} \]
    8. Taylor expanded in z around inf 93.9%

      \[\leadsto \color{blue}{\frac{1}{y \cdot z}} \cdot \frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{x} \]
    9. Taylor expanded in z around 0 42.9%

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

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

Alternative 11: 58.5% accurate, 2.2× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ 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_m] = \mathsf{sort}([x_m, y_m, z_m])\\ \\ y\_s \cdot \left(x\_s \cdot \frac{1}{y\_m \cdot x\_m}\right) \end{array} \]
z_m = (fabs.f64 z)
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_m should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z_m)
 :precision binary64
 (* y_s (* x_s (/ 1.0 (* y_m x_m)))))
z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
	return y_s * (x_s * (1.0 / (y_m * x_m)));
}
z_m = abs(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_m should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z_m)
    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_m
    code = y_s * (x_s * (1.0d0 / (y_m * x_m)))
end function
z_m = Math.abs(z);
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_m;
public static double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
	return y_s * (x_s * (1.0 / (y_m * x_m)));
}
z_m = math.fabs(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_m] = sort([x_m, y_m, z_m])
def code(y_s, x_s, x_m, y_m, z_m):
	return y_s * (x_s * (1.0 / (y_m * x_m)))
z_m = abs(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_m = sort([x_m, y_m, z_m])
function code(y_s, x_s, x_m, y_m, z_m)
	return Float64(y_s * Float64(x_s * Float64(1.0 / Float64(y_m * x_m))))
end
z_m = abs(z);
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_m = num2cell(sort([x_m, y_m, z_m])){:}
function tmp = code(y_s, x_s, x_m, y_m, z_m)
	tmp = y_s * (x_s * (1.0 / (y_m * x_m)));
end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(x$95$s * N[(1.0 / N[(y$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
y\_s \cdot \left(x\_s \cdot \frac{1}{y\_m \cdot x\_m}\right)
\end{array}
Derivation
  1. Initial program 95.3%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{y \cdot \left(x \cdot \mathsf{fma}\left(z, z, 1\right)\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in z around 0 65.1%

    \[\leadsto \frac{1}{y \cdot \color{blue}{x}} \]
  6. Final simplification65.1%

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

Developer target: 92.8% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + z \cdot z\\ t_1 := y \cdot t\_0\\ t_2 := \frac{\frac{1}{y}}{t\_0 \cdot x}\\ \mathbf{if}\;t\_1 < -\infty:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 < 8.680743250567252 \cdot 10^{+305}:\\ \;\;\;\;\frac{\frac{1}{x}}{t\_0 \cdot y}\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ 1.0 (* z z))) (t_1 (* y t_0)) (t_2 (/ (/ 1.0 y) (* t_0 x))))
   (if (< t_1 (- INFINITY))
     t_2
     (if (< t_1 8.680743250567252e+305) (/ (/ 1.0 x) (* t_0 y)) t_2))))
double code(double x, double y, double z) {
	double t_0 = 1.0 + (z * z);
	double t_1 = y * t_0;
	double t_2 = (1.0 / y) / (t_0 * x);
	double tmp;
	if (t_1 < -((double) INFINITY)) {
		tmp = t_2;
	} else if (t_1 < 8.680743250567252e+305) {
		tmp = (1.0 / x) / (t_0 * y);
	} else {
		tmp = t_2;
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	double t_0 = 1.0 + (z * z);
	double t_1 = y * t_0;
	double t_2 = (1.0 / y) / (t_0 * x);
	double tmp;
	if (t_1 < -Double.POSITIVE_INFINITY) {
		tmp = t_2;
	} else if (t_1 < 8.680743250567252e+305) {
		tmp = (1.0 / x) / (t_0 * y);
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 1.0 + (z * z)
	t_1 = y * t_0
	t_2 = (1.0 / y) / (t_0 * x)
	tmp = 0
	if t_1 < -math.inf:
		tmp = t_2
	elif t_1 < 8.680743250567252e+305:
		tmp = (1.0 / x) / (t_0 * y)
	else:
		tmp = t_2
	return tmp
function code(x, y, z)
	t_0 = Float64(1.0 + Float64(z * z))
	t_1 = Float64(y * t_0)
	t_2 = Float64(Float64(1.0 / y) / Float64(t_0 * x))
	tmp = 0.0
	if (t_1 < Float64(-Inf))
		tmp = t_2;
	elseif (t_1 < 8.680743250567252e+305)
		tmp = Float64(Float64(1.0 / x) / Float64(t_0 * y));
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 1.0 + (z * z);
	t_1 = y * t_0;
	t_2 = (1.0 / y) / (t_0 * x);
	tmp = 0.0;
	if (t_1 < -Inf)
		tmp = t_2;
	elseif (t_1 < 8.680743250567252e+305)
		tmp = (1.0 / x) / (t_0 * y);
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(1.0 / y), $MachinePrecision] / N[(t$95$0 * x), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$1, (-Infinity)], t$95$2, If[Less[t$95$1, 8.680743250567252e+305], N[(N[(1.0 / x), $MachinePrecision] / N[(t$95$0 * y), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 + z \cdot z\\
t_1 := y \cdot t\_0\\
t_2 := \frac{\frac{1}{y}}{t\_0 \cdot x}\\
\mathbf{if}\;t\_1 < -\infty:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_1 < 8.680743250567252 \cdot 10^{+305}:\\
\;\;\;\;\frac{\frac{1}{x}}{t\_0 \cdot y}\\

\mathbf{else}:\\
\;\;\;\;t\_2\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024089 
(FPCore (x y z)
  :name "Statistics.Distribution.CauchyLorentz:$cdensity from math-functions-0.1.5.2"
  :precision binary64

  :alt
  (if (< (* y (+ 1.0 (* z z))) (- INFINITY)) (/ (/ 1.0 y) (* (+ 1.0 (* z z)) x)) (if (< (* y (+ 1.0 (* z z))) 8.680743250567252e+305) (/ (/ 1.0 x) (* (+ 1.0 (* z z)) y)) (/ (/ 1.0 y) (* (+ 1.0 (* z z)) x))))

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