Average Error: 6.4 → 0.7
Time: 9.6s
Precision: binary64
Cost: 1736
\[ \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)\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;\frac{\frac{\frac{1}{y}}{z}}{z \cdot x}\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+303}:\\ \;\;\;\;\frac{\frac{1}{x}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z \cdot \left(y \cdot \left(z \cdot x\right)\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 (* y (+ 1.0 (* z z)))))
   (if (<= t_0 (- INFINITY))
     (/ (/ (/ 1.0 y) z) (* z x))
     (if (<= t_0 5e+303) (/ (/ 1.0 x) t_0) (/ 1.0 (* z (* y (* z x))))))))
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 tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = ((1.0 / y) / z) / (z * x);
	} else if (t_0 <= 5e+303) {
		tmp = (1.0 / x) / t_0;
	} else {
		tmp = 1.0 / (z * (y * (z * x)));
	}
	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 tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = ((1.0 / y) / z) / (z * x);
	} else if (t_0 <= 5e+303) {
		tmp = (1.0 / x) / t_0;
	} else {
		tmp = 1.0 / (z * (y * (z * x)));
	}
	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))
	tmp = 0
	if t_0 <= -math.inf:
		tmp = ((1.0 / y) / z) / (z * x)
	elif t_0 <= 5e+303:
		tmp = (1.0 / x) / t_0
	else:
		tmp = 1.0 / (z * (y * (z * x)))
	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)))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(Float64(Float64(1.0 / y) / z) / Float64(z * x));
	elseif (t_0 <= 5e+303)
		tmp = Float64(Float64(1.0 / x) / t_0);
	else
		tmp = Float64(1.0 / Float64(z * Float64(y * Float64(z * x))));
	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));
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = ((1.0 / y) / z) / (z * x);
	elseif (t_0 <= 5e+303)
		tmp = (1.0 / x) / t_0;
	else
		tmp = 1.0 / (z * (y * (z * x)));
	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]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(N[(1.0 / y), $MachinePrecision] / z), $MachinePrecision] / N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+303], N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $MachinePrecision], N[(1.0 / N[(z * N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\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)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\frac{\frac{\frac{1}{y}}{z}}{z \cdot x}\\

\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+303}:\\
\;\;\;\;\frac{\frac{1}{x}}{t_0}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.4
Target5.1
Herbie0.7
\[\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 3 regimes
  2. if (*.f64 y (+.f64 1 (*.f64 z z))) < -inf.0

    1. Initial program 15.5

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

      \[\leadsto \color{blue}{\frac{1}{x \cdot \left(y \cdot \mathsf{fma}\left(z, z, 1\right)\right)}} \]
      Proof
      (/.f64 1 (*.f64 x (*.f64 y (fma.f64 z z 1)))): 0 points increase in error, 0 points decrease in error
      (/.f64 1 (*.f64 x (*.f64 y (Rewrite<= fma-def_binary64 (+.f64 (*.f64 z z) 1))))): 0 points increase in error, 0 points decrease in error
      (/.f64 1 (*.f64 x (*.f64 y (Rewrite<= +-commutative_binary64 (+.f64 1 (*.f64 z z)))))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-/r*_binary64 (/.f64 (/.f64 1 x) (*.f64 y (+.f64 1 (*.f64 z z))))): 33 points increase in error, 26 points decrease in error
    3. Taylor expanded in z around inf 15.5

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

      \[\leadsto \color{blue}{\frac{\frac{1}{y}}{z \cdot \left(z \cdot x\right)}} \]
      Proof
      (/.f64 (/.f64 1 y) (*.f64 z (*.f64 z x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (/.f64 1 y) (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 z z) x))): 39 points increase in error, 16 points decrease in error
      (/.f64 (/.f64 1 y) (*.f64 (Rewrite<= unpow2_binary64 (pow.f64 z 2)) x)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-/r*_binary64 (/.f64 1 (*.f64 y (*.f64 (pow.f64 z 2) x)))): 14 points increase in error, 22 points decrease in error
    5. Applied egg-rr1.3

      \[\leadsto \color{blue}{\frac{\frac{1}{y}}{z} \cdot \frac{1}{z \cdot x}} \]
    6. Taylor expanded in y around 0 15.5

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

      \[\leadsto \color{blue}{\frac{\frac{\frac{1}{y}}{z}}{z \cdot x}} \]
      Proof
      (/.f64 (/.f64 (/.f64 1 y) z) (*.f64 z x)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-/r*_binary64 (/.f64 (/.f64 1 y) (*.f64 z (*.f64 z x)))): 36 points increase in error, 21 points decrease in error
      (/.f64 (/.f64 1 y) (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 z z) x))): 39 points increase in error, 16 points decrease in error
      (/.f64 (/.f64 1 y) (*.f64 (Rewrite<= unpow2_binary64 (pow.f64 z 2)) x)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-/r*_binary64 (/.f64 1 (*.f64 y (*.f64 (pow.f64 z 2) x)))): 14 points increase in error, 22 points decrease in error

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

    1. Initial program 0.3

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

    if 4.9999999999999997e303 < (*.f64 y (+.f64 1 (*.f64 z z)))

    1. Initial program 18.5

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

      \[\leadsto \color{blue}{\frac{1}{x \cdot \left(y \cdot \mathsf{fma}\left(z, z, 1\right)\right)}} \]
      Proof
      (/.f64 1 (*.f64 x (*.f64 y (fma.f64 z z 1)))): 0 points increase in error, 0 points decrease in error
      (/.f64 1 (*.f64 x (*.f64 y (Rewrite<= fma-def_binary64 (+.f64 (*.f64 z z) 1))))): 0 points increase in error, 0 points decrease in error
      (/.f64 1 (*.f64 x (*.f64 y (Rewrite<= +-commutative_binary64 (+.f64 1 (*.f64 z z)))))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-/r*_binary64 (/.f64 (/.f64 1 x) (*.f64 y (+.f64 1 (*.f64 z z))))): 33 points increase in error, 26 points decrease in error
    3. Taylor expanded in z around inf 14.6

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

      \[\leadsto \frac{1}{\color{blue}{z \cdot \left(y \cdot \left(z \cdot x\right)\right)}} \]
      Proof
      (*.f64 z (*.f64 y (*.f64 z x))): 0 points increase in error, 0 points decrease in error
      (*.f64 z (*.f64 y (Rewrite<= *-commutative_binary64 (*.f64 x z)))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> *-commutative_binary64 (*.f64 (*.f64 y (*.f64 x z)) z)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*r*_binary64 (*.f64 y (*.f64 (*.f64 x z) z))): 25 points increase in error, 21 points decrease in error
      (*.f64 y (Rewrite<= associate-*r*_binary64 (*.f64 x (*.f64 z z)))): 27 points increase in error, 29 points decrease in error
      (*.f64 y (*.f64 x (Rewrite<= unpow2_binary64 (pow.f64 z 2)))): 0 points increase in error, 0 points decrease in error
      (*.f64 y (Rewrite<= *-commutative_binary64 (*.f64 (pow.f64 z 2) x))): 0 points increase in error, 0 points decrease in error
  3. Recombined 3 regimes into one program.
  4. Final simplification0.7

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

Alternatives

Alternative 1
Error1.7
Cost968
\[\begin{array}{l} t_0 := \frac{1}{z \cdot \left(y \cdot \left(z \cdot x\right)\right)}\\ \mathbf{if}\;z \leq -2.0675549489035357 \cdot 10^{+64}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.6883028561814425 \cdot 10^{+80}:\\ \;\;\;\;\frac{1}{x \cdot \left(y + y \cdot \left(z \cdot z\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error2.2
Cost840
\[\begin{array}{l} t_0 := \frac{\frac{\frac{1}{y}}{z}}{z \cdot x}\\ \mathbf{if}\;z \leq -1256362614861945600:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error1.9
Cost836
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 0.02:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(y \cdot z\right)}\\ \end{array} \]
Alternative 4
Error2.0
Cost836
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 0.02:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z \cdot \left(y \cdot \left(z \cdot x\right)\right)}\\ \end{array} \]
Alternative 5
Error28.6
Cost320
\[\frac{\frac{1}{y}}{x} \]
Alternative 6
Error28.5
Cost320
\[\frac{1}{y \cdot x} \]

Error

Reproduce

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