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

Percentage Accurate: 90.4% → 99.6%
Time: 8.1s
Alternatives: 10
Speedup: 0.6×

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 10 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: 90.4% 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.6% accurate, 0.0× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} t_0 := \sqrt{y} \cdot \mathsf{hypot}\left(1, z\right)\\ t_1 := y \cdot \left(1 + z \cdot z\right)\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;{\left(\frac{\frac{\sqrt{\frac{-1}{x}}}{\sqrt{-y}}}{z}\right)}^{2}\\ \mathbf{elif}\;t_1 \leq 10^{+292}:\\ \;\;\;\;\frac{\frac{1}{x}}{y + y \cdot {z}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{t_0} \cdot \frac{\frac{1}{x}}{t_0}\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (sqrt y) (hypot 1.0 z))) (t_1 (* y (+ 1.0 (* z z)))))
   (if (<= t_1 (- INFINITY))
     (pow (/ (/ (sqrt (/ -1.0 x)) (sqrt (- y))) z) 2.0)
     (if (<= t_1 1e+292)
       (/ (/ 1.0 x) (+ y (* y (pow z 2.0))))
       (* (/ 1.0 t_0) (/ (/ 1.0 x) t_0))))))
assert(x < y);
double code(double x, double y, double z) {
	double t_0 = sqrt(y) * hypot(1.0, z);
	double t_1 = y * (1.0 + (z * z));
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = pow(((sqrt((-1.0 / x)) / sqrt(-y)) / z), 2.0);
	} else if (t_1 <= 1e+292) {
		tmp = (1.0 / x) / (y + (y * pow(z, 2.0)));
	} else {
		tmp = (1.0 / t_0) * ((1.0 / x) / t_0);
	}
	return tmp;
}
assert x < y;
public static double code(double x, double y, double z) {
	double t_0 = Math.sqrt(y) * Math.hypot(1.0, z);
	double t_1 = y * (1.0 + (z * z));
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = Math.pow(((Math.sqrt((-1.0 / x)) / Math.sqrt(-y)) / z), 2.0);
	} else if (t_1 <= 1e+292) {
		tmp = (1.0 / x) / (y + (y * Math.pow(z, 2.0)));
	} else {
		tmp = (1.0 / t_0) * ((1.0 / x) / t_0);
	}
	return tmp;
}
[x, y] = sort([x, y])
def code(x, y, z):
	t_0 = math.sqrt(y) * math.hypot(1.0, z)
	t_1 = y * (1.0 + (z * z))
	tmp = 0
	if t_1 <= -math.inf:
		tmp = math.pow(((math.sqrt((-1.0 / x)) / math.sqrt(-y)) / z), 2.0)
	elif t_1 <= 1e+292:
		tmp = (1.0 / x) / (y + (y * math.pow(z, 2.0)))
	else:
		tmp = (1.0 / t_0) * ((1.0 / x) / t_0)
	return tmp
x, y = sort([x, y])
function code(x, y, z)
	t_0 = Float64(sqrt(y) * hypot(1.0, z))
	t_1 = Float64(y * Float64(1.0 + Float64(z * z)))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(Float64(sqrt(Float64(-1.0 / x)) / sqrt(Float64(-y))) / z) ^ 2.0;
	elseif (t_1 <= 1e+292)
		tmp = Float64(Float64(1.0 / x) / Float64(y + Float64(y * (z ^ 2.0))));
	else
		tmp = Float64(Float64(1.0 / t_0) * Float64(Float64(1.0 / x) / t_0));
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
	t_0 = sqrt(y) * hypot(1.0, z);
	t_1 = y * (1.0 + (z * z));
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = ((sqrt((-1.0 / x)) / sqrt(-y)) / z) ^ 2.0;
	elseif (t_1 <= 1e+292)
		tmp = (1.0 / x) / (y + (y * (z ^ 2.0)));
	else
		tmp = (1.0 / t_0) * ((1.0 / x) / t_0);
	end
	tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sqrt[y], $MachinePrecision] * N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[Power[N[(N[(N[Sqrt[N[(-1.0 / x), $MachinePrecision]], $MachinePrecision] / N[Sqrt[(-y)], $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], 2.0], $MachinePrecision], If[LessEqual[t$95$1, 1e+292], N[(N[(1.0 / x), $MachinePrecision] / N[(y + N[(y * N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \sqrt{y} \cdot \mathsf{hypot}\left(1, z\right)\\
t_1 := y \cdot \left(1 + z \cdot z\right)\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;{\left(\frac{\frac{\sqrt{\frac{-1}{x}}}{\sqrt{-y}}}{z}\right)}^{2}\\

\mathbf{elif}\;t_1 \leq 10^{+292}:\\
\;\;\;\;\frac{\frac{1}{x}}{y + y \cdot {z}^{2}}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{t_0} \cdot \frac{\frac{1}{x}}{t_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 y (+.f64 1 (*.f64 z z))) < -inf.0

    1. Initial program 69.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{y}}{x \cdot {z}^{2}}} \cdot \sqrt{\frac{\frac{1}{y}}{x \cdot {z}^{2}}}} \]
      2. pow269.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\frac{\color{blue}{\frac{\sqrt{-\frac{1}{x}}}{\sqrt{-y}}}}{z}\right)}^{2} \]
      7. distribute-neg-frac46.5%

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

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

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

    if -inf.0 < (*.f64 y (+.f64 1 (*.f64 z z))) < 1e292

    1. Initial program 99.7%

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

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

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

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

    if 1e292 < (*.f64 y (+.f64 1 (*.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. *-un-lft-identity69.9%

        \[\leadsto \frac{\color{blue}{1 \cdot \frac{1}{x}}}{y \cdot \left(1 + z \cdot z\right)} \]
      2. 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)}}} \]
      3. 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)}}} \]
      4. sqrt-prod69.9%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(1 + z \cdot z\right) \leq -\infty:\\ \;\;\;\;{\left(\frac{\frac{\sqrt{\frac{-1}{x}}}{\sqrt{-y}}}{z}\right)}^{2}\\ \mathbf{elif}\;y \cdot \left(1 + z \cdot z\right) \leq 10^{+292}:\\ \;\;\;\;\frac{\frac{1}{x}}{y + y \cdot {z}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{y} \cdot \mathsf{hypot}\left(1, z\right)} \cdot \frac{\frac{1}{x}}{\sqrt{y} \cdot \mathsf{hypot}\left(1, z\right)}\\ \end{array} \]

Alternative 2: 78.2% accurate, 0.1× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+145}:\\ \;\;\;\;\frac{\frac{1}{x}}{y + y \cdot {z}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{\frac{\frac{1}{x}}{y}}{z}}{\sqrt{z}}}{\sqrt{z}}\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= (* z z) 2e+145)
   (/ (/ 1.0 x) (+ y (* y (pow z 2.0))))
   (/ (/ (/ (/ (/ 1.0 x) y) z) (sqrt z)) (sqrt z))))
assert(x < y);
double code(double x, double y, double z) {
	double tmp;
	if ((z * z) <= 2e+145) {
		tmp = (1.0 / x) / (y + (y * pow(z, 2.0)));
	} else {
		tmp = ((((1.0 / x) / y) / z) / sqrt(z)) / sqrt(z);
	}
	return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((z * z) <= 2d+145) then
        tmp = (1.0d0 / x) / (y + (y * (z ** 2.0d0)))
    else
        tmp = ((((1.0d0 / x) / y) / z) / sqrt(z)) / sqrt(z)
    end if
    code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
	double tmp;
	if ((z * z) <= 2e+145) {
		tmp = (1.0 / x) / (y + (y * Math.pow(z, 2.0)));
	} else {
		tmp = ((((1.0 / x) / y) / z) / Math.sqrt(z)) / Math.sqrt(z);
	}
	return tmp;
}
[x, y] = sort([x, y])
def code(x, y, z):
	tmp = 0
	if (z * z) <= 2e+145:
		tmp = (1.0 / x) / (y + (y * math.pow(z, 2.0)))
	else:
		tmp = ((((1.0 / x) / y) / z) / math.sqrt(z)) / math.sqrt(z)
	return tmp
x, y = sort([x, y])
function code(x, y, z)
	tmp = 0.0
	if (Float64(z * z) <= 2e+145)
		tmp = Float64(Float64(1.0 / x) / Float64(y + Float64(y * (z ^ 2.0))));
	else
		tmp = Float64(Float64(Float64(Float64(Float64(1.0 / x) / y) / z) / sqrt(z)) / sqrt(z));
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z * z) <= 2e+145)
		tmp = (1.0 / x) / (y + (y * (z ^ 2.0)));
	else
		tmp = ((((1.0 / x) / y) / z) / sqrt(z)) / sqrt(z);
	end
	tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+145], N[(N[(1.0 / x), $MachinePrecision] / N[(y + N[(y * N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision] / z), $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+145}:\\
\;\;\;\;\frac{\frac{1}{x}}{y + y \cdot {z}^{2}}\\

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


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

    1. Initial program 99.1%

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

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

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

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

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

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

    if 2e145 < (*.f64 z z)

    1. Initial program 72.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{y}}{x \cdot {z}^{2}}} \cdot \sqrt{\frac{\frac{1}{y}}{x \cdot {z}^{2}}}} \]
      2. pow267.4%

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\frac{{\left(x \cdot y\right)}^{-0.5}}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}\right)}^{2} \]
      11. add-sqr-sqrt52.4%

        \[\leadsto {\left(\frac{{\left(x \cdot y\right)}^{-0.5}}{\color{blue}{z}}\right)}^{2} \]
    6. Applied egg-rr52.4%

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

        \[\leadsto \color{blue}{\frac{{\left(x \cdot y\right)}^{-0.5}}{z} \cdot \frac{{\left(x \cdot y\right)}^{-0.5}}{z}} \]
      2. add-sqr-sqrt34.9%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{{\left(x \cdot y\right)}^{-0.5}}{z}} \cdot \sqrt{\frac{{\left(x \cdot y\right)}^{-0.5}}{z}}\right)} \cdot \frac{{\left(x \cdot y\right)}^{-0.5}}{z} \]
      3. associate-*l*34.9%

        \[\leadsto \color{blue}{\sqrt{\frac{{\left(x \cdot y\right)}^{-0.5}}{z}} \cdot \left(\sqrt{\frac{{\left(x \cdot y\right)}^{-0.5}}{z}} \cdot \frac{{\left(x \cdot y\right)}^{-0.5}}{z}\right)} \]
      4. sqrt-div26.6%

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

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

        \[\leadsto \frac{{\left(x \cdot y\right)}^{\color{blue}{-0.25}}}{\sqrt{z}} \cdot \left(\sqrt{\frac{{\left(x \cdot y\right)}^{-0.5}}{z}} \cdot \frac{{\left(x \cdot y\right)}^{-0.5}}{z}\right) \]
      7. sqrt-div26.6%

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

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

        \[\leadsto \frac{{\left(x \cdot y\right)}^{-0.25}}{\sqrt{z}} \cdot \left(\frac{{\left(x \cdot y\right)}^{\color{blue}{-0.25}}}{\sqrt{z}} \cdot \frac{{\left(x \cdot y\right)}^{-0.5}}{z}\right) \]
    8. Applied egg-rr26.6%

      \[\leadsto \color{blue}{\frac{{\left(x \cdot y\right)}^{-0.25}}{\sqrt{z}} \cdot \left(\frac{{\left(x \cdot y\right)}^{-0.25}}{\sqrt{z}} \cdot \frac{{\left(x \cdot y\right)}^{-0.5}}{z}\right)} \]
    9. Step-by-step derivation
      1. associate-*l/26.6%

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

        \[\leadsto \frac{{\left(x \cdot y\right)}^{-0.25} \cdot \color{blue}{\frac{{\left(x \cdot y\right)}^{-0.25} \cdot \frac{{\left(x \cdot y\right)}^{-0.5}}{z}}{\sqrt{z}}}}{\sqrt{z}} \]
      3. associate-*r/26.5%

        \[\leadsto \frac{\color{blue}{\frac{{\left(x \cdot y\right)}^{-0.25} \cdot \left({\left(x \cdot y\right)}^{-0.25} \cdot \frac{{\left(x \cdot y\right)}^{-0.5}}{z}\right)}{\sqrt{z}}}}{\sqrt{z}} \]
      4. associate-*l*26.5%

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

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

        \[\leadsto \frac{\frac{{\left(x \cdot y\right)}^{\color{blue}{-0.5}} \cdot \frac{{\left(x \cdot y\right)}^{-0.5}}{z}}{\sqrt{z}}}{\sqrt{z}} \]
      7. associate-*r/25.7%

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

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

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

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

        \[\leadsto \frac{\frac{\frac{\color{blue}{\frac{\frac{1}{x}}{y}}}{z}}{\sqrt{z}}}{\sqrt{z}} \]
    10. Simplified43.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+145}:\\ \;\;\;\;\frac{\frac{1}{x}}{y + y \cdot {z}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{\frac{\frac{1}{x}}{y}}{z}}{\sqrt{z}}}{\sqrt{z}}\\ \end{array} \]

Alternative 3: 94.7% accurate, 0.1× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 6 \cdot 10^{-297}:\\ \;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\ \mathbf{elif}\;y \leq 10^{-41}:\\ \;\;\;\;\frac{\frac{1}{x}}{y + {\left(z \cdot \sqrt{y}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y}}{x \cdot \mathsf{fma}\left(z, z, 1\right)}\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= y 6e-297)
   (/ (/ 1.0 x) (* y (+ 1.0 (* z z))))
   (if (<= y 1e-41)
     (/ (/ 1.0 x) (+ y (pow (* z (sqrt y)) 2.0)))
     (/ (/ 1.0 y) (* x (fma z z 1.0))))))
assert(x < y);
double code(double x, double y, double z) {
	double tmp;
	if (y <= 6e-297) {
		tmp = (1.0 / x) / (y * (1.0 + (z * z)));
	} else if (y <= 1e-41) {
		tmp = (1.0 / x) / (y + pow((z * sqrt(y)), 2.0));
	} else {
		tmp = (1.0 / y) / (x * fma(z, z, 1.0));
	}
	return tmp;
}
x, y = sort([x, y])
function code(x, y, z)
	tmp = 0.0
	if (y <= 6e-297)
		tmp = Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z))));
	elseif (y <= 1e-41)
		tmp = Float64(Float64(1.0 / x) / Float64(y + (Float64(z * sqrt(y)) ^ 2.0)));
	else
		tmp = Float64(Float64(1.0 / y) / Float64(x * fma(z, z, 1.0)));
	end
	return tmp
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[y, 6e-297], N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1e-41], N[(N[(1.0 / x), $MachinePrecision] / N[(y + N[Power[N[(z * N[Sqrt[y], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] / N[(x * N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6 \cdot 10^{-297}:\\
\;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 5.9999999999999999e-297

    1. Initial program 89.7%

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

    if 5.9999999999999999e-297 < y < 1.00000000000000001e-41

    1. Initial program 87.9%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{\sqrt{y \cdot {z}^{2}} \cdot \sqrt{y \cdot {z}^{2}}} + y} \]
      2. pow287.8%

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

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

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

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

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

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

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

    if 1.00000000000000001e-41 < y

    1. Initial program 88.6%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 6 \cdot 10^{-297}:\\ \;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\ \mathbf{elif}\;y \leq 10^{-41}:\\ \;\;\;\;\frac{\frac{1}{x}}{y + {\left(z \cdot \sqrt{y}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y}}{x \cdot \mathsf{fma}\left(z, z, 1\right)}\\ \end{array} \]

Alternative 4: 90.4% accurate, 0.1× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \frac{\frac{1}{y}}{x \cdot \mathsf{fma}\left(z, z, 1\right)} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z) :precision binary64 (/ (/ 1.0 y) (* x (fma z z 1.0))))
assert(x < y);
double code(double x, double y, double z) {
	return (1.0 / y) / (x * fma(z, z, 1.0));
}
x, y = sort([x, y])
function code(x, y, z)
	return Float64(Float64(1.0 / y) / Float64(x * fma(z, z, 1.0)))
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_] := N[(N[(1.0 / y), $MachinePrecision] / N[(x * N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{1}{y}}{x \cdot \mathsf{fma}\left(z, z, 1\right)}
\end{array}
Derivation
  1. Initial program 89.1%

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 92.4% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} t_0 := y \cdot \left(1 + z \cdot z\right)\\ \mathbf{if}\;t_0 \leq 2 \cdot 10^{+305}:\\ \;\;\;\;\frac{\frac{1}{x}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y \cdot x} \cdot \left(\frac{1}{z} \cdot \frac{1}{z}\right)\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (+ 1.0 (* z z)))))
   (if (<= t_0 2e+305)
     (/ (/ 1.0 x) t_0)
     (* (/ 1.0 (* y x)) (* (/ 1.0 z) (/ 1.0 z))))))
assert(x < y);
double code(double x, double y, double z) {
	double t_0 = y * (1.0 + (z * z));
	double tmp;
	if (t_0 <= 2e+305) {
		tmp = (1.0 / x) / t_0;
	} else {
		tmp = (1.0 / (y * x)) * ((1.0 / z) * (1.0 / z));
	}
	return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = y * (1.0d0 + (z * z))
    if (t_0 <= 2d+305) then
        tmp = (1.0d0 / x) / t_0
    else
        tmp = (1.0d0 / (y * x)) * ((1.0d0 / z) * (1.0d0 / z))
    end if
    code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
	double t_0 = y * (1.0 + (z * z));
	double tmp;
	if (t_0 <= 2e+305) {
		tmp = (1.0 / x) / t_0;
	} else {
		tmp = (1.0 / (y * x)) * ((1.0 / z) * (1.0 / z));
	}
	return tmp;
}
[x, y] = sort([x, y])
def code(x, y, z):
	t_0 = y * (1.0 + (z * z))
	tmp = 0
	if t_0 <= 2e+305:
		tmp = (1.0 / x) / t_0
	else:
		tmp = (1.0 / (y * x)) * ((1.0 / z) * (1.0 / z))
	return tmp
x, y = sort([x, y])
function code(x, y, z)
	t_0 = Float64(y * Float64(1.0 + Float64(z * z)))
	tmp = 0.0
	if (t_0 <= 2e+305)
		tmp = Float64(Float64(1.0 / x) / t_0);
	else
		tmp = Float64(Float64(1.0 / Float64(y * x)) * Float64(Float64(1.0 / z) * Float64(1.0 / z)));
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
	t_0 = y * (1.0 + (z * z));
	tmp = 0.0;
	if (t_0 <= 2e+305)
		tmp = (1.0 / x) / t_0;
	else
		tmp = (1.0 / (y * x)) * ((1.0 / z) * (1.0 / z));
	end
	tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2e+305], N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(1.0 / N[(y * x), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / z), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := y \cdot \left(1 + z \cdot z\right)\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{+305}:\\
\;\;\;\;\frac{\frac{1}{x}}{t_0}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 y (+.f64 1 (*.f64 z z))) < 1.9999999999999999e305

    1. Initial program 93.5%

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

    if 1.9999999999999999e305 < (*.f64 y (+.f64 1 (*.f64 z z)))

    1. Initial program 67.1%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{y}}{\color{blue}{x \cdot {z}^{2}}} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt73.3%

        \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{y}}{x \cdot {z}^{2}}} \cdot \sqrt{\frac{\frac{1}{y}}{x \cdot {z}^{2}}}} \]
      2. pow273.3%

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\frac{{\left(x \cdot y\right)}^{-0.5}}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}\right)}^{2} \]
      11. add-sqr-sqrt58.0%

        \[\leadsto {\left(\frac{{\left(x \cdot y\right)}^{-0.5}}{\color{blue}{z}}\right)}^{2} \]
    6. Applied egg-rr58.0%

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

        \[\leadsto \color{blue}{\frac{{\left(x \cdot y\right)}^{-0.5}}{z} \cdot \frac{{\left(x \cdot y\right)}^{-0.5}}{z}} \]
      2. div-inv58.0%

        \[\leadsto \color{blue}{\left({\left(x \cdot y\right)}^{-0.5} \cdot \frac{1}{z}\right)} \cdot \frac{{\left(x \cdot y\right)}^{-0.5}}{z} \]
      3. div-inv58.0%

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

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

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

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

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

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

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

Alternative 6: 92.2% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} t_0 := y \cdot \left(1 + z \cdot z\right)\\ \mathbf{if}\;t_0 \leq 2 \cdot 10^{+305}:\\ \;\;\;\;\frac{\frac{1}{x}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-1}{y \cdot x}}{z \cdot \left(-z\right)}\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (+ 1.0 (* z z)))))
   (if (<= t_0 2e+305) (/ (/ 1.0 x) t_0) (/ (/ -1.0 (* y x)) (* z (- z))))))
assert(x < y);
double code(double x, double y, double z) {
	double t_0 = y * (1.0 + (z * z));
	double tmp;
	if (t_0 <= 2e+305) {
		tmp = (1.0 / x) / t_0;
	} else {
		tmp = (-1.0 / (y * x)) / (z * -z);
	}
	return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = y * (1.0d0 + (z * z))
    if (t_0 <= 2d+305) then
        tmp = (1.0d0 / x) / t_0
    else
        tmp = ((-1.0d0) / (y * x)) / (z * -z)
    end if
    code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
	double t_0 = y * (1.0 + (z * z));
	double tmp;
	if (t_0 <= 2e+305) {
		tmp = (1.0 / x) / t_0;
	} else {
		tmp = (-1.0 / (y * x)) / (z * -z);
	}
	return tmp;
}
[x, y] = sort([x, y])
def code(x, y, z):
	t_0 = y * (1.0 + (z * z))
	tmp = 0
	if t_0 <= 2e+305:
		tmp = (1.0 / x) / t_0
	else:
		tmp = (-1.0 / (y * x)) / (z * -z)
	return tmp
x, y = sort([x, y])
function code(x, y, z)
	t_0 = Float64(y * Float64(1.0 + Float64(z * z)))
	tmp = 0.0
	if (t_0 <= 2e+305)
		tmp = Float64(Float64(1.0 / x) / t_0);
	else
		tmp = Float64(Float64(-1.0 / Float64(y * x)) / Float64(z * Float64(-z)));
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
	t_0 = y * (1.0 + (z * z));
	tmp = 0.0;
	if (t_0 <= 2e+305)
		tmp = (1.0 / x) / t_0;
	else
		tmp = (-1.0 / (y * x)) / (z * -z);
	end
	tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2e+305], N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(-1.0 / N[(y * x), $MachinePrecision]), $MachinePrecision] / N[(z * (-z)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := y \cdot \left(1 + z \cdot z\right)\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{+305}:\\
\;\;\;\;\frac{\frac{1}{x}}{t_0}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 y (+.f64 1 (*.f64 z z))) < 1.9999999999999999e305

    1. Initial program 93.5%

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

    if 1.9999999999999999e305 < (*.f64 y (+.f64 1 (*.f64 z z)))

    1. Initial program 67.1%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{y}}{\color{blue}{x \cdot {z}^{2}}} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt73.3%

        \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{y}}{x \cdot {z}^{2}}} \cdot \sqrt{\frac{\frac{1}{y}}{x \cdot {z}^{2}}}} \]
      2. pow273.3%

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\frac{{\left(x \cdot y\right)}^{-0.5}}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}\right)}^{2} \]
      11. add-sqr-sqrt58.0%

        \[\leadsto {\left(\frac{{\left(x \cdot y\right)}^{-0.5}}{\color{blue}{z}}\right)}^{2} \]
    6. Applied egg-rr58.0%

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

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

        \[\leadsto \color{blue}{\frac{-{\left(x \cdot y\right)}^{-0.5}}{-z}} \cdot \frac{{\left(x \cdot y\right)}^{-0.5}}{z} \]
      3. frac-times49.4%

        \[\leadsto \color{blue}{\frac{\left(-{\left(x \cdot y\right)}^{-0.5}\right) \cdot {\left(x \cdot y\right)}^{-0.5}}{\left(-z\right) \cdot z}} \]
      4. distribute-lft-neg-in49.4%

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

        \[\leadsto \frac{-\color{blue}{{\left(x \cdot y\right)}^{\left(-0.5 + -0.5\right)}}}{\left(-z\right) \cdot z} \]
      6. metadata-eval77.9%

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{-1}}{\frac{x \cdot y}{1}}}{\left(-z\right) \cdot z} \]
      11. /-rgt-identity77.9%

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

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

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

Alternative 7: 74.4% accurate, 0.9× speedup?

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

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


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

    1. Initial program 92.1%

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{y}}{x}} \]
    4. Simplified67.2%

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

    if 1 < z

    1. Initial program 80.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{y}}{x \cdot {z}^{2}}} \cdot \sqrt{\frac{\frac{1}{y}}{x \cdot {z}^{2}}}} \]
      2. pow260.0%

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\frac{{\left(x \cdot y\right)}^{-0.5}}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}\right)}^{2} \]
      11. add-sqr-sqrt51.4%

        \[\leadsto {\left(\frac{{\left(x \cdot y\right)}^{-0.5}}{\color{blue}{z}}\right)}^{2} \]
    6. Applied egg-rr51.4%

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

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

        \[\leadsto \color{blue}{\frac{-{\left(x \cdot y\right)}^{-0.5}}{-z}} \cdot \frac{{\left(x \cdot y\right)}^{-0.5}}{z} \]
      3. frac-times43.6%

        \[\leadsto \color{blue}{\frac{\left(-{\left(x \cdot y\right)}^{-0.5}\right) \cdot {\left(x \cdot y\right)}^{-0.5}}{\left(-z\right) \cdot z}} \]
      4. distribute-lft-neg-in43.6%

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

        \[\leadsto \frac{-\color{blue}{{\left(x \cdot y\right)}^{\left(-0.5 + -0.5\right)}}}{\left(-z\right) \cdot z} \]
      6. metadata-eval82.5%

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{-1}}{\frac{x \cdot y}{1}}}{\left(-z\right) \cdot z} \]
      11. /-rgt-identity82.5%

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

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

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

Alternative 8: 58.2% accurate, 2.2× speedup?

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

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

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

    \[\leadsto \frac{1}{y \cdot x} \]

Alternative 9: 58.3% accurate, 2.2× speedup?

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

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

    \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y}} \]
  3. Final simplification53.2%

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

Alternative 10: 58.3% accurate, 2.2× speedup?

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{y}}{x}} \]
  4. Simplified53.2%

    \[\leadsto \color{blue}{\frac{\frac{1}{y}}{x}} \]
  5. Final simplification53.2%

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

Developer target: 92.5% accurate, 0.4× 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 2023318 
(FPCore (x y z)
  :name "Statistics.Distribution.CauchyLorentz:$cdensity from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (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)))))