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

Percentage Accurate: 91.0% → 97.6%
Time: 12.2s
Alternatives: 8
Speedup: 0.7×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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: 91.0% 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: 97.6% accurate, 0.1× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+206}:\\ \;\;\;\;\frac{\frac{1}{y}}{x \cdot \mathsf{fma}\left(z, z, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{1}{x}}{z \cdot y}}{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) 5e+206)
   (/ (/ 1.0 y) (* x (fma z z 1.0)))
   (/ (/ (/ 1.0 x) (* z y)) z)))
assert(x < y);
double code(double x, double y, double z) {
	double tmp;
	if ((z * z) <= 5e+206) {
		tmp = (1.0 / y) / (x * fma(z, z, 1.0));
	} else {
		tmp = ((1.0 / x) / (z * y)) / z;
	}
	return tmp;
}
x, y = sort([x, y])
function code(x, y, z)
	tmp = 0.0
	if (Float64(z * z) <= 5e+206)
		tmp = Float64(Float64(1.0 / y) / Float64(x * fma(z, z, 1.0)));
	else
		tmp = Float64(Float64(Float64(1.0 / x) / Float64(z * y)) / z);
	end
	return 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], 5e+206], N[(N[(1.0 / y), $MachinePrecision] / N[(x * N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / x), $MachinePrecision] / N[(z * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+206}:\\
\;\;\;\;\frac{\frac{1}{y}}{x \cdot \mathsf{fma}\left(z, z, 1\right)}\\

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


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

    1. Initial program 97.4%

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

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

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

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

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

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

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

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

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

    if 5.0000000000000002e206 < (*.f64 z z)

    1. Initial program 76.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.6% accurate, 0.1× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{y \cdot \left(\mathsf{hypot}\left(1, z\right) \cdot x\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 (hypot 1.0 z)) (* y (* (hypot 1.0 z) x))))
assert(x < y);
double code(double x, double y, double z) {
	return (1.0 / hypot(1.0, z)) / (y * (hypot(1.0, z) * x));
}
assert x < y;
public static double code(double x, double y, double z) {
	return (1.0 / Math.hypot(1.0, z)) / (y * (Math.hypot(1.0, z) * x));
}
[x, y] = sort([x, y])
def code(x, y, z):
	return (1.0 / math.hypot(1.0, z)) / (y * (math.hypot(1.0, z) * x))
x, y = sort([x, y])
function code(x, y, z)
	return Float64(Float64(1.0 / hypot(1.0, z)) / Float64(y * Float64(hypot(1.0, z) * x)))
end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
	tmp = (1.0 / hypot(1.0, z)) / (y * (hypot(1.0, z) * x));
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_] := N[(N[(1.0 / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] / N[(y * N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{y \cdot \left(\mathsf{hypot}\left(1, z\right) \cdot x\right)}
\end{array}
Derivation
  1. Initial program 90.2%

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

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

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

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

      \[\leadsto \frac{1 \cdot \frac{1}{x \cdot y}}{\color{blue}{z \cdot z + 1}} \]
    5. fma-udef89.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 97.4% accurate, 0.1× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \frac{\frac{1}{y \cdot \left(\mathsf{hypot}\left(1, z\right) \cdot x\right)}}{\mathsf{hypot}\left(1, z\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 (* (hypot 1.0 z) x))) (hypot 1.0 z)))
assert(x < y);
double code(double x, double y, double z) {
	return (1.0 / (y * (hypot(1.0, z) * x))) / hypot(1.0, z);
}
assert x < y;
public static double code(double x, double y, double z) {
	return (1.0 / (y * (Math.hypot(1.0, z) * x))) / Math.hypot(1.0, z);
}
[x, y] = sort([x, y])
def code(x, y, z):
	return (1.0 / (y * (math.hypot(1.0, z) * x))) / math.hypot(1.0, z)
x, y = sort([x, y])
function code(x, y, z)
	return Float64(Float64(1.0 / Float64(y * Float64(hypot(1.0, z) * x))) / hypot(1.0, z))
end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
	tmp = (1.0 / (y * (hypot(1.0, z) * x))) / hypot(1.0, z);
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_] := N[(N[(1.0 / N[(y * N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{1}{y \cdot \left(\mathsf{hypot}\left(1, z\right) \cdot x\right)}}{\mathsf{hypot}\left(1, z\right)}
\end{array}
Derivation
  1. Initial program 90.2%

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

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

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

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

      \[\leadsto \frac{1 \cdot \frac{1}{x \cdot y}}{\color{blue}{z \cdot z + 1}} \]
    5. fma-udef89.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 97.6% accurate, 0.7× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+38}:\\ \;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z} \cdot \frac{\frac{1}{y}}{z \cdot x}\\ \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) 5e+38)
   (/ (/ 1.0 x) (* y (+ 1.0 (* z z))))
   (* (/ 1.0 z) (/ (/ 1.0 y) (* z x)))))
assert(x < y);
double code(double x, double y, double z) {
	double tmp;
	if ((z * z) <= 5e+38) {
		tmp = (1.0 / x) / (y * (1.0 + (z * z)));
	} else {
		tmp = (1.0 / z) * ((1.0 / y) / (z * x));
	}
	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) <= 5d+38) then
        tmp = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
    else
        tmp = (1.0d0 / z) * ((1.0d0 / y) / (z * x))
    end if
    code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
	double tmp;
	if ((z * z) <= 5e+38) {
		tmp = (1.0 / x) / (y * (1.0 + (z * z)));
	} else {
		tmp = (1.0 / z) * ((1.0 / y) / (z * x));
	}
	return tmp;
}
[x, y] = sort([x, y])
def code(x, y, z):
	tmp = 0
	if (z * z) <= 5e+38:
		tmp = (1.0 / x) / (y * (1.0 + (z * z)))
	else:
		tmp = (1.0 / z) * ((1.0 / y) / (z * x))
	return tmp
x, y = sort([x, y])
function code(x, y, z)
	tmp = 0.0
	if (Float64(z * z) <= 5e+38)
		tmp = Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z))));
	else
		tmp = Float64(Float64(1.0 / z) * Float64(Float64(1.0 / y) / Float64(z * x)));
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z * z) <= 5e+38)
		tmp = (1.0 / x) / (y * (1.0 + (z * z)));
	else
		tmp = (1.0 / z) * ((1.0 / y) / (z * x));
	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], 5e+38], N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / z), $MachinePrecision] * N[(N[(1.0 / y), $MachinePrecision] / N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+38}:\\
\;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\

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


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

    1. Initial program 99.7%

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

    if 4.9999999999999997e38 < (*.f64 z z)

    1. Initial program 81.1%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{z} \cdot \color{blue}{\frac{\frac{1}{y}}{z \cdot x}} \]
    8. Simplified97.5%

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

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

Alternative 5: 78.0% accurate, 0.8× 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{1}{z} \cdot \frac{\frac{1}{y}}{z \cdot x}\\ \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 z) (/ (/ 1.0 y) (* z x)))))
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 / z) * ((1.0 / y) / (z * x));
	}
	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 / z) * ((1.0d0 / y) / (z * x))
    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 / z) * ((1.0 / y) / (z * x));
	}
	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 / z) * ((1.0 / y) / (z * x))
	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 / z) * Float64(Float64(1.0 / y) / Float64(z * x)));
	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 / z) * ((1.0 / y) / (z * x));
	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 / z), $MachinePrecision] * N[(N[(1.0 / y), $MachinePrecision] / N[(z * x), $MachinePrecision]), $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{1}{z} \cdot \frac{\frac{1}{y}}{z \cdot x}\\


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

    1. Initial program 93.3%

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

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

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

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

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

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

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

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

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

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

    if 1 < z

    1. Initial program 82.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 76.7% accurate, 1.0× 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{1}{z \cdot \left(z \cdot \left(y \cdot x\right)\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 (* z (* z (* y x))))))
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 / (z * (z * (y * x)));
	}
	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 / (z * (z * (y * x)))
    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 / (z * (z * (y * x)));
	}
	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 / (z * (z * (y * x)))
	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(1.0 / Float64(z * Float64(z * Float64(y * x))));
	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 / (z * (z * (y * x)));
	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[(1.0 / N[(z * N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]), $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{1}{z \cdot \left(z \cdot \left(y \cdot x\right)\right)}\\


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

    1. Initial program 93.3%

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

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

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

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

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

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

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

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

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

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

    if 1 < z

    1. Initial program 82.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{\frac{1}{y}}{x}}{z} \cdot \frac{1}{z}} \]
      2. clear-num88.6%

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

        \[\leadsto \color{blue}{\frac{1 \cdot 1}{\frac{z}{\frac{\frac{1}{y}}{x}} \cdot z}} \]
      4. metadata-eval88.2%

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

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

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

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

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

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

Alternative 7: 78.1% accurate, 1.0× 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}{z}}{x \cdot \left(z \cdot y\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 z) (* x (* z y)))))
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 / z) / (x * (z * y));
	}
	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 / z) / (x * (z * y))
    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 / z) / (x * (z * y));
	}
	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 / z) / (x * (z * y))
	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 / z) / Float64(x * Float64(z * y)));
	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 / z) / (x * (z * y));
	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 / z), $MachinePrecision] / N[(x * N[(z * y), $MachinePrecision]), $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}{z}}{x \cdot \left(z \cdot y\right)}\\


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

    1. Initial program 93.3%

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

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

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

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

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

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

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

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

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

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

    if 1 < z

    1. Initial program 82.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 1:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(z \cdot y\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 90.2%

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

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

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

Developer target: 92.8% 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 2023301 
(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)))))