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

Percentage Accurate: 89.7% → 99.2%
Time: 10.0s
Alternatives: 8
Speedup: 0.8×

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{1}{\sqrt{y}}}{\mathsf{hypot}\left(1, z\_m\right)}}{\sqrt{y} \cdot \left(z\_m \cdot x\_m\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.9999999999999999e304

    1. Initial program 94.5%

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

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

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

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

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

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

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

    if 1.9999999999999999e304 < (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z)))

    1. Initial program 69.9%

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

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

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

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

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

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

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

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

      \[\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. associate-*r*72.3%

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

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

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

        \[\leadsto \frac{\frac{1}{\color{blue}{y \cdot x}}}{\mathsf{fma}\left(z, z, 1\right)} \]
      5. associate-/l/72.3%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\sqrt{y \cdot \color{blue}{\mathsf{fma}\left(z, z, 1\right)}}} \cdot \frac{\frac{1}{x}}{\sqrt{y \cdot \left(1 + z \cdot z\right)}} \]
      14. *-commutative69.9%

        \[\leadsto \frac{1}{\sqrt{\color{blue}{\mathsf{fma}\left(z, z, 1\right) \cdot y}}} \cdot \frac{\frac{1}{x}}{\sqrt{y \cdot \left(1 + z \cdot z\right)}} \]
      15. sqrt-prod69.9%

        \[\leadsto \frac{1}{\color{blue}{\sqrt{\mathsf{fma}\left(z, z, 1\right)} \cdot \sqrt{y}}} \cdot \frac{\frac{1}{x}}{\sqrt{y \cdot \left(1 + z \cdot z\right)}} \]
      16. fma-undefine69.9%

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

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

        \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(1, z\right)} \cdot \sqrt{y}} \cdot \frac{\frac{1}{x}}{\sqrt{y \cdot \left(1 + z \cdot z\right)}} \]
      19. +-commutative69.9%

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{\mathsf{hypot}\left(1, z\right) \cdot \sqrt{y}} \cdot 1}{\left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{y}\right) \cdot x}} \]
      3. *-rgt-identity99.7%

        \[\leadsto \frac{\color{blue}{\frac{1}{\mathsf{hypot}\left(1, z\right) \cdot \sqrt{y}}}}{\left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{y}\right) \cdot x} \]
      4. *-commutative99.7%

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

        \[\leadsto \frac{\color{blue}{\frac{\frac{1}{\sqrt{y}}}{\mathsf{hypot}\left(1, z\right)}}}{\left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{y}\right) \cdot x} \]
      6. *-commutative99.6%

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

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

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

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

Alternative 2: 99.4% 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) \\ [x_m, y, z_m] = \mathsf{sort}([x_m, y, z_m])\\ \\ x\_s \cdot \frac{\frac{\frac{1}{\sqrt{y}}}{\mathsf{hypot}\left(1, z\_m\right)}}{x\_m \cdot \left(\sqrt{y} \cdot \mathsf{hypot}\left(1, z\_m\right)\right)} \end{array} \]
z_m = (fabs.f64 z)
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z_m)
 :precision binary64
 (*
  x_s
  (/
   (/ (/ 1.0 (sqrt y)) (hypot 1.0 z_m))
   (* x_m (* (sqrt y) (hypot 1.0 z_m))))))
z_m = fabs(z);
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z_m);
double code(double x_s, double x_m, double y, double z_m) {
	return x_s * (((1.0 / sqrt(y)) / hypot(1.0, z_m)) / (x_m * (sqrt(y) * hypot(1.0, z_m))));
}
z_m = Math.abs(z);
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z_m;
public static double code(double x_s, double x_m, double y, double z_m) {
	return x_s * (((1.0 / Math.sqrt(y)) / Math.hypot(1.0, z_m)) / (x_m * (Math.sqrt(y) * Math.hypot(1.0, z_m))));
}
z_m = math.fabs(z)
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
[x_m, y, z_m] = sort([x_m, y, z_m])
def code(x_s, x_m, y, z_m):
	return x_s * (((1.0 / math.sqrt(y)) / math.hypot(1.0, z_m)) / (x_m * (math.sqrt(y) * math.hypot(1.0, z_m))))
z_m = abs(z)
x\_m = abs(x)
x\_s = copysign(1.0, x)
x_m, y, z_m = sort([x_m, y, z_m])
function code(x_s, x_m, y, z_m)
	return Float64(x_s * Float64(Float64(Float64(1.0 / sqrt(y)) / hypot(1.0, z_m)) / Float64(x_m * Float64(sqrt(y) * hypot(1.0, z_m)))))
end
z_m = abs(z);
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z_m = num2cell(sort([x_m, y, z_m])){:}
function tmp = code(x_s, x_m, y, z_m)
	tmp = x_s * (((1.0 / sqrt(y)) / hypot(1.0, z_m)) / (x_m * (sqrt(y) * hypot(1.0, z_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]
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z$95$m_] := N[(x$95$s * N[(N[(N[(1.0 / N[Sqrt[y], $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z$95$m ^ 2], $MachinePrecision]), $MachinePrecision] / N[(x$95$m * N[(N[Sqrt[y], $MachinePrecision] * N[Sqrt[1.0 ^ 2 + z$95$m ^ 2], $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)
\\
[x_m, y, z_m] = \mathsf{sort}([x_m, y, z_m])\\
\\
x\_s \cdot \frac{\frac{\frac{1}{\sqrt{y}}}{\mathsf{hypot}\left(1, z\_m\right)}}{x\_m \cdot \left(\sqrt{y} \cdot \mathsf{hypot}\left(1, z\_m\right)\right)}
\end{array}
Derivation
  1. Initial program 91.1%

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

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

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

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

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

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

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

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

    \[\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. associate-*r*89.2%

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

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

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

      \[\leadsto \frac{\frac{1}{\color{blue}{y \cdot x}}}{\mathsf{fma}\left(z, z, 1\right)} \]
    5. associate-/l/89.3%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\sqrt{y \cdot \color{blue}{\mathsf{fma}\left(z, z, 1\right)}}} \cdot \frac{\frac{1}{x}}{\sqrt{y \cdot \left(1 + z \cdot z\right)}} \]
    14. *-commutative42.9%

      \[\leadsto \frac{1}{\sqrt{\color{blue}{\mathsf{fma}\left(z, z, 1\right) \cdot y}}} \cdot \frac{\frac{1}{x}}{\sqrt{y \cdot \left(1 + z \cdot z\right)}} \]
    15. sqrt-prod42.9%

      \[\leadsto \frac{1}{\color{blue}{\sqrt{\mathsf{fma}\left(z, z, 1\right)} \cdot \sqrt{y}}} \cdot \frac{\frac{1}{x}}{\sqrt{y \cdot \left(1 + z \cdot z\right)}} \]
    16. fma-undefine42.9%

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

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

      \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(1, z\right)} \cdot \sqrt{y}} \cdot \frac{\frac{1}{x}}{\sqrt{y \cdot \left(1 + z \cdot z\right)}} \]
    19. +-commutative42.9%

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\mathsf{hypot}\left(1, z\right) \cdot \sqrt{y}} \cdot 1}{\left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{y}\right) \cdot x}} \]
    3. *-rgt-identity46.9%

      \[\leadsto \frac{\color{blue}{\frac{1}{\mathsf{hypot}\left(1, z\right) \cdot \sqrt{y}}}}{\left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{y}\right) \cdot x} \]
    4. *-commutative46.9%

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

      \[\leadsto \frac{\color{blue}{\frac{\frac{1}{\sqrt{y}}}{\mathsf{hypot}\left(1, z\right)}}}{\left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{y}\right) \cdot x} \]
    6. *-commutative47.0%

      \[\leadsto \frac{\frac{\frac{1}{\sqrt{y}}}{\mathsf{hypot}\left(1, z\right)}}{\color{blue}{x \cdot \left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{y}\right)}} \]
  8. Simplified47.0%

    \[\leadsto \color{blue}{\frac{\frac{\frac{1}{\sqrt{y}}}{\mathsf{hypot}\left(1, z\right)}}{x \cdot \left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{y}\right)}} \]
  9. Final simplification47.0%

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

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

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


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

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

      \[\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. associate-*r*96.2%

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

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

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

        \[\leadsto \frac{\frac{1}{\color{blue}{y \cdot x}}}{\mathsf{fma}\left(z, z, 1\right)} \]
      5. associate-/l/96.3%

        \[\leadsto \frac{\color{blue}{\frac{\frac{1}{x}}{y}}}{\mathsf{fma}\left(z, z, 1\right)} \]
      6. associate-/r*98.6%

        \[\leadsto \color{blue}{\frac{\frac{1}{x}}{y \cdot \mathsf{fma}\left(z, z, 1\right)}} \]
      7. *-un-lft-identity98.6%

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

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

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

    if 4.99999999999999993e306 < (*.f64 z z)

    1. Initial program 65.0%

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

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

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

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

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

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

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

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

      \[\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-sqrt32.9%

        \[\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. pow232.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{1}{y} \cdot \frac{1}{x}}}{{z}^{2}} \]
      6. unpow264.6%

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

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

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

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

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


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

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

    if 4.99999999999999993e306 < (*.f64 z z)

    1. Initial program 65.0%

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

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

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

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

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

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

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

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

      \[\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-sqrt32.9%

        \[\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. pow232.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{1}{y} \cdot \frac{1}{x}}}{{z}^{2}} \]
      6. unpow264.6%

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

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

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

Alternative 5: 97.8% accurate, 0.6× speedup?

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

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


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

    1. Initial program 99.6%

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

    if 3e48 < (*.f64 z z)

    1. Initial program 81.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{y \cdot \left(x \cdot \color{blue}{\mathsf{fma}\left(z, z, 1\right)}\right)} \]
    3. Simplified75.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-sqrt32.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. pow232.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 94.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{y \cdot \left(x \cdot \color{blue}{\mathsf{fma}\left(z, z, 1\right)}\right)} \]
    3. Simplified92.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-sqrt41.5%

        \[\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. pow241.5%

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

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

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

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

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

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

      \[\leadsto \frac{1}{y \cdot \color{blue}{{\left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{x}\right)}^{2}}} \]
    7. Step-by-step derivation
      1. unpow241.9%

        \[\leadsto \frac{1}{y \cdot \color{blue}{\left(\left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{x}\right) \cdot \left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{x}\right)\right)}} \]
      2. associate-*l*41.9%

        \[\leadsto \frac{1}{y \cdot \color{blue}{\left(\mathsf{hypot}\left(1, z\right) \cdot \left(\sqrt{x} \cdot \left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{x}\right)\right)\right)}} \]
      3. *-commutative41.9%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{y}}{x}} \]
    11. Simplified72.1%

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

    if 1 < z

    1. Initial program 81.1%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{y \cdot \left(x \cdot \color{blue}{\mathsf{fma}\left(z, z, 1\right)}\right)} \]
    3. Simplified77.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-sqrt43.0%

        \[\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. pow243.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 95.8% accurate, 0.8× speedup?

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

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


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

    1. Initial program 94.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{y \cdot \left(x \cdot \color{blue}{\mathsf{fma}\left(z, z, 1\right)}\right)} \]
    3. Simplified92.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-sqrt41.5%

        \[\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. pow241.5%

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

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

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

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

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

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

      \[\leadsto \frac{1}{y \cdot \color{blue}{{\left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{x}\right)}^{2}}} \]
    7. Step-by-step derivation
      1. unpow241.9%

        \[\leadsto \frac{1}{y \cdot \color{blue}{\left(\left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{x}\right) \cdot \left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{x}\right)\right)}} \]
      2. associate-*l*41.9%

        \[\leadsto \frac{1}{y \cdot \color{blue}{\left(\mathsf{hypot}\left(1, z\right) \cdot \left(\sqrt{x} \cdot \left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{x}\right)\right)\right)}} \]
      3. *-commutative41.9%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{y}}{x}} \]
    11. Simplified72.1%

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

    if 1 < z

    1. Initial program 81.1%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{y \cdot \left(x \cdot \color{blue}{\mathsf{fma}\left(z, z, 1\right)}\right)} \]
    3. Simplified77.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-sqrt43.0%

        \[\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. pow243.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 58.0% 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) \\ [x_m, y, z_m] = \mathsf{sort}([x_m, y, z_m])\\ \\ x\_s \cdot \frac{1}{y \cdot x\_m} \end{array} \]
z_m = (fabs.f64 z)
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z_m) :precision binary64 (* x_s (/ 1.0 (* y x_m))))
z_m = fabs(z);
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z_m);
double code(double x_s, double x_m, double y, double z_m) {
	return x_s * (1.0 / (y * x_m));
}
z_m = abs(z)
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z_m)
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    code = x_s * (1.0d0 / (y * x_m))
end function
z_m = Math.abs(z);
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z_m;
public static double code(double x_s, double x_m, double y, double z_m) {
	return x_s * (1.0 / (y * x_m));
}
z_m = math.fabs(z)
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
[x_m, y, z_m] = sort([x_m, y, z_m])
def code(x_s, x_m, y, z_m):
	return x_s * (1.0 / (y * x_m))
z_m = abs(z)
x\_m = abs(x)
x\_s = copysign(1.0, x)
x_m, y, z_m = sort([x_m, y, z_m])
function code(x_s, x_m, y, z_m)
	return Float64(x_s * Float64(1.0 / Float64(y * x_m)))
end
z_m = abs(z);
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z_m = num2cell(sort([x_m, y, z_m])){:}
function tmp = code(x_s, x_m, y, z_m)
	tmp = x_s * (1.0 / (y * 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]
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z$95$m_] := N[(x$95$s * N[(1.0 / N[(y * x$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)
\\
[x_m, y, z_m] = \mathsf{sort}([x_m, y, z_m])\\
\\
x\_s \cdot \frac{1}{y \cdot x\_m}
\end{array}
Derivation
  1. Initial program 91.1%

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

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

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

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

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

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

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

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

    \[\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 59.3%

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

Developer target: 92.7% 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 2024086 
(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)))))