Average Error: 6.4 → 5.0
Time: 6.2s
Precision: binary64
\[[x, y] = \mathsf{sort}([x, y]) \\]
\[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
\[\begin{array}{l} t_0 := \sqrt{\mathsf{fma}\left(z, z, 1\right)}\\ \mathbf{if}\;y \leq 3.958220094131283 \cdot 10^{-17}:\\ \;\;\;\;\frac{\frac{1}{x}}{\left(t_0 \cdot y\right) \cdot t_0 + \mathsf{fma}\left(0, y, 0 \cdot y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{1}{x}}{y}}{\mathsf{fma}\left(z, z, 1\right)}\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (sqrt (fma z z 1.0))))
   (if (<= y 3.958220094131283e-17)
     (/ (/ 1.0 x) (+ (* (* t_0 y) t_0) (fma 0.0 y (* 0.0 y))))
     (/ (/ (/ 1.0 x) y) (fma z z 1.0)))))
double code(double x, double y, double z) {
	return (1.0 / x) / (y * (1.0 + (z * z)));
}
double code(double x, double y, double z) {
	double t_0 = sqrt(fma(z, z, 1.0));
	double tmp;
	if (y <= 3.958220094131283e-17) {
		tmp = (1.0 / x) / (((t_0 * y) * t_0) + fma(0.0, y, (0.0 * y)));
	} else {
		tmp = ((1.0 / x) / y) / fma(z, z, 1.0);
	}
	return tmp;
}
function code(x, y, z)
	return Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z))))
end
function code(x, y, z)
	t_0 = sqrt(fma(z, z, 1.0))
	tmp = 0.0
	if (y <= 3.958220094131283e-17)
		tmp = Float64(Float64(1.0 / x) / Float64(Float64(Float64(t_0 * y) * t_0) + fma(0.0, y, Float64(0.0 * y))));
	else
		tmp = Float64(Float64(Float64(1.0 / x) / y) / fma(z, z, 1.0));
	end
	return tmp
end
code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[Sqrt[N[(z * z + 1.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 3.958220094131283e-17], N[(N[(1.0 / x), $MachinePrecision] / N[(N[(N[(t$95$0 * y), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(0.0 * y + N[(0.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision] / N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]]]
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\begin{array}{l}
t_0 := \sqrt{\mathsf{fma}\left(z, z, 1\right)}\\
\mathbf{if}\;y \leq 3.958220094131283 \cdot 10^{-17}:\\
\;\;\;\;\frac{\frac{1}{x}}{\left(t_0 \cdot y\right) \cdot t_0 + \mathsf{fma}\left(0, y, 0 \cdot y\right)}\\

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


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.4
Target4.9
Herbie5.0
\[\begin{array}{l} \mathbf{if}\;y \cdot \left(1 + z \cdot z\right) < -\infty:\\ \;\;\;\;\frac{\frac{1}{y}}{\left(1 + z \cdot z\right) \cdot x}\\ \mathbf{elif}\;y \cdot \left(1 + z \cdot z\right) < 8.680743250567252 \cdot 10^{+305}:\\ \;\;\;\;\frac{\frac{1}{x}}{\left(1 + z \cdot z\right) \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y}}{\left(1 + z \cdot z\right) \cdot x}\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. if y < 3.9582200941312828e-17

    1. Initial program 8.0

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

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

      \[\leadsto \frac{\frac{1}{x}}{\color{blue}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(z, z, 1\right)}, y \cdot \sqrt{\mathsf{fma}\left(z, z, 1\right)}, -0 \cdot y\right) + \mathsf{fma}\left(0, y, 0 \cdot y\right)}} \]
    4. Applied egg-rr8.0

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

    if 3.9582200941312828e-17 < y

    1. Initial program 4.8

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

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

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

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

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

Reproduce

herbie shell --seed 2022131 
(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)))))