Average Error: 6.4 → 0.8
Time: 10.9s
Precision: binary64
Cost: 14280
\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ \end{array} \]
\[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
\[\begin{array}{l} t_0 := y \cdot \left(1 + z \cdot z\right)\\ t_1 := \frac{\frac{\frac{\frac{1}{z}}{x}}{y}}{z}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+301}:\\ \;\;\;\;\frac{\frac{{\left(\mathsf{hypot}\left(1, z\right)\right)}^{-2}}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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 (* y (+ 1.0 (* z z)))) (t_1 (/ (/ (/ (/ 1.0 z) x) y) z)))
   (if (<= t_0 (- INFINITY))
     t_1
     (if (<= t_0 5e+301) (/ (/ (pow (hypot 1.0 z) -2.0) y) x) t_1))))
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 = y * (1.0 + (z * z));
	double t_1 = (((1.0 / z) / x) / y) / z;
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_0 <= 5e+301) {
		tmp = (pow(hypot(1.0, z), -2.0) / y) / x;
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	return (1.0 / x) / (y * (1.0 + (z * z)));
}
public static double code(double x, double y, double z) {
	double t_0 = y * (1.0 + (z * z));
	double t_1 = (((1.0 / z) / x) / y) / z;
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if (t_0 <= 5e+301) {
		tmp = (Math.pow(Math.hypot(1.0, z), -2.0) / y) / x;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	return (1.0 / x) / (y * (1.0 + (z * z)))
def code(x, y, z):
	t_0 = y * (1.0 + (z * z))
	t_1 = (((1.0 / z) / x) / y) / z
	tmp = 0
	if t_0 <= -math.inf:
		tmp = t_1
	elif t_0 <= 5e+301:
		tmp = (math.pow(math.hypot(1.0, z), -2.0) / y) / x
	else:
		tmp = t_1
	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 = Float64(y * Float64(1.0 + Float64(z * z)))
	t_1 = Float64(Float64(Float64(Float64(1.0 / z) / x) / y) / z)
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_0 <= 5e+301)
		tmp = Float64(Float64((hypot(1.0, z) ^ -2.0) / y) / x);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = (1.0 / x) / (y * (1.0 + (z * z)));
end
function tmp_2 = code(x, y, z)
	t_0 = y * (1.0 + (z * z));
	t_1 = (((1.0 / z) / x) / y) / z;
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = t_1;
	elseif (t_0 <= 5e+301)
		tmp = ((hypot(1.0, z) ^ -2.0) / y) / x;
	else
		tmp = t_1;
	end
	tmp_2 = 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[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(1.0 / z), $MachinePrecision] / x), $MachinePrecision] / y), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$1, If[LessEqual[t$95$0, 5e+301], N[(N[(N[Power[N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision], -2.0], $MachinePrecision] / y), $MachinePrecision] / x), $MachinePrecision], t$95$1]]]]
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\begin{array}{l}
t_0 := y \cdot \left(1 + z \cdot z\right)\\
t_1 := \frac{\frac{\frac{\frac{1}{z}}{x}}{y}}{z}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+301}:\\
\;\;\;\;\frac{\frac{{\left(\mathsf{hypot}\left(1, z\right)\right)}^{-2}}{y}}{x}\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.4
Target5.0
Herbie0.8
\[\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 (*.f64 y (+.f64 1 (*.f64 z z))) < -inf.0 or 5.0000000000000004e301 < (*.f64 y (+.f64 1 (*.f64 z z)))

    1. Initial program 18.1

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

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

      \[\leadsto \frac{\frac{1}{x}}{\color{blue}{z \cdot \left(y \cdot z\right)}} \]
      Proof
      (*.f64 z (*.f64 y z)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= *-commutative_binary64 (*.f64 (*.f64 y z) z)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*r*_binary64 (*.f64 y (*.f64 z z))): 38 points increase in error, 28 points decrease in error
      (*.f64 y (Rewrite<= unpow2_binary64 (pow.f64 z 2))): 0 points increase in error, 0 points decrease in error
    4. Applied egg-rr3.3

      \[\leadsto \color{blue}{\frac{1}{z \cdot y} \cdot \frac{1}{z \cdot x}} \]
    5. Applied egg-rr1.8

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

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

    1. Initial program 0.3

      \[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
    2. Applied egg-rr0.3

      \[\leadsto \color{blue}{0 + \frac{\frac{{\left(\mathsf{hypot}\left(1, z\right)\right)}^{-2}}{y}}{x}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

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

Alternatives

Alternative 1
Error0.8
Cost1736
\[\begin{array}{l} t_0 := y \cdot \left(1 + z \cdot z\right)\\ t_1 := \frac{\frac{\frac{\frac{1}{z}}{x}}{y}}{z}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+301}:\\ \;\;\;\;\frac{\frac{1}{x}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error1.7
Cost972
\[\begin{array}{l} t_0 := \frac{\frac{\frac{\frac{1}{z}}{x}}{y}}{z}\\ \mathbf{if}\;z \leq -1000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.305522661766507 \cdot 10^{+26}:\\ \;\;\;\;\frac{1}{x \cdot \left(y + y \cdot \left(z \cdot z\right)\right)}\\ \mathbf{elif}\;z \leq 1.789201186525958 \cdot 10^{+105}:\\ \;\;\;\;\frac{\frac{\frac{1}{z}}{y}}{z \cdot x}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error1.7
Cost964
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 5000000000000:\\ \;\;\;\;\frac{1}{y \cdot \left(x + z \cdot \left(z \cdot x\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{z}}{y \cdot \left(z \cdot x\right)}\\ \end{array} \]
Alternative 4
Error2.7
Cost840
\[\begin{array}{l} t_0 := \frac{\frac{\frac{1}{z}}{y}}{z \cdot x}\\ \mathbf{if}\;z \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 10^{-25}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error2.8
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;\frac{\frac{1}{z}}{y \cdot \left(z \cdot x\right)}\\ \mathbf{elif}\;z \leq 10^{-25}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{1}{z}}{y}}{z \cdot x}\\ \end{array} \]
Alternative 6
Error2.8
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;\frac{\frac{\frac{\frac{1}{z}}{x}}{y}}{z}\\ \mathbf{elif}\;z \leq 10^{-25}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{1}{z}}{y}}{z \cdot x}\\ \end{array} \]
Alternative 7
Error28.9
Cost320
\[\frac{\frac{1}{y}}{x} \]
Alternative 8
Error28.9
Cost320
\[\frac{1}{y \cdot x} \]

Error

Reproduce

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