?

Average Error: 6.4 → 0.6
Time: 11.0s
Precision: binary64
Cost: 26948

?

\[ \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 := \sqrt{y} \cdot \mathsf{hypot}\left(1, z\right)\\ \mathbf{if}\;y \cdot \left(1 + z \cdot z\right) \leq 5 \cdot 10^{+305}:\\ \;\;\;\;\frac{\frac{1}{x}}{y + z \cdot \left(y \cdot z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{t_0 \cdot \left(x \cdot t_0\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 y) (hypot 1.0 z))))
   (if (<= (* y (+ 1.0 (* z z))) 5e+305)
     (/ (/ 1.0 x) (+ y (* z (* y z))))
     (/ 1.0 (* t_0 (* x t_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(y) * hypot(1.0, z);
	double tmp;
	if ((y * (1.0 + (z * z))) <= 5e+305) {
		tmp = (1.0 / x) / (y + (z * (y * z)));
	} else {
		tmp = 1.0 / (t_0 * (x * t_0));
	}
	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 = Math.sqrt(y) * Math.hypot(1.0, z);
	double tmp;
	if ((y * (1.0 + (z * z))) <= 5e+305) {
		tmp = (1.0 / x) / (y + (z * (y * z)));
	} else {
		tmp = 1.0 / (t_0 * (x * t_0));
	}
	return tmp;
}
def code(x, y, z):
	return (1.0 / x) / (y * (1.0 + (z * z)))
def code(x, y, z):
	t_0 = math.sqrt(y) * math.hypot(1.0, z)
	tmp = 0
	if (y * (1.0 + (z * z))) <= 5e+305:
		tmp = (1.0 / x) / (y + (z * (y * z)))
	else:
		tmp = 1.0 / (t_0 * (x * t_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 = Float64(sqrt(y) * hypot(1.0, z))
	tmp = 0.0
	if (Float64(y * Float64(1.0 + Float64(z * z))) <= 5e+305)
		tmp = Float64(Float64(1.0 / x) / Float64(y + Float64(z * Float64(y * z))));
	else
		tmp = Float64(1.0 / Float64(t_0 * Float64(x * t_0)));
	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 = sqrt(y) * hypot(1.0, z);
	tmp = 0.0;
	if ((y * (1.0 + (z * z))) <= 5e+305)
		tmp = (1.0 / x) / (y + (z * (y * z)));
	else
		tmp = 1.0 / (t_0 * (x * t_0));
	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[(N[Sqrt[y], $MachinePrecision] * N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+305], N[(N[(1.0 / x), $MachinePrecision] / N[(y + N[(z * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(t$95$0 * N[(x * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\begin{array}{l}
t_0 := \sqrt{y} \cdot \mathsf{hypot}\left(1, z\right)\\
\mathbf{if}\;y \cdot \left(1 + z \cdot z\right) \leq 5 \cdot 10^{+305}:\\
\;\;\;\;\frac{\frac{1}{x}}{y + z \cdot \left(y \cdot z\right)}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.4
Target5.1
Herbie0.6
\[\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))) < 5.00000000000000009e305

    1. Initial program 1.9

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

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

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

    1. Initial program 18.4

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

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

      [Start]18.4

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

      associate-/l/ [=>]18.4

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

      associate-*l* [=>]13.5

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

      +-commutative [=>]13.5

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

      fma-def [=>]13.5

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

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

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

      [Start]13.6

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

      associate-/l/ [=>]13.6

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

      associate-/r/ [=>]13.5

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

      /-rgt-identity [=>]13.5

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

      fma-udef [=>]13.5

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

      +-commutative [<=]13.5

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

      hypot-1-def [=>]13.5

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

      *-commutative [=>]13.5

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

      fma-udef [=>]13.5

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

      +-commutative [<=]13.5

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

      hypot-1-def [=>]0.8

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

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

Alternatives

Alternative 1
Error1.1
Cost13636
\[\begin{array}{l} \mathbf{if}\;x \leq -40000000000000:\\ \;\;\;\;\frac{\frac{1}{x}}{y + z \cdot \left(y \cdot z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(y \cdot \mathsf{hypot}\left(1, z\right)\right) \cdot \left(x \cdot \mathsf{hypot}\left(1, z\right)\right)}\\ \end{array} \]
Alternative 2
Error3.7
Cost968
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{+17}:\\ \;\;\;\;\frac{\frac{1}{z \cdot \left(y \cdot z\right)}}{x}\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{+51}:\\ \;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y}}{z \cdot \left(z \cdot x\right)}\\ \end{array} \]
Alternative 3
Error4.3
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\ \;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(y \cdot z\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{y}\\ \end{array} \]
Alternative 4
Error4.3
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(y \cdot z\right)\right)}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{\frac{1}{x}}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y \cdot \left(z \cdot \left(z \cdot x\right)\right)}\\ \end{array} \]
Alternative 5
Error4.3
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -0.86:\\ \;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(y \cdot z\right)\right)}\\ \mathbf{elif}\;z \leq 0.86:\\ \;\;\;\;\frac{1 - z \cdot z}{y \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y \cdot \left(z \cdot \left(z \cdot x\right)\right)}\\ \end{array} \]
Alternative 6
Error4.3
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -0.86:\\ \;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(y \cdot z\right)\right)}\\ \mathbf{elif}\;z \leq 0.86:\\ \;\;\;\;\frac{1 - z \cdot z}{y \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y}}{z \cdot \left(z \cdot x\right)}\\ \end{array} \]
Alternative 7
Error2.4
Cost836
\[\begin{array}{l} \mathbf{if}\;y \leq 5 \cdot 10^{-38}:\\ \;\;\;\;\frac{\frac{1}{x}}{y + z \cdot \left(y \cdot z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{1}{x}}{y}}{1 + z \cdot z}\\ \end{array} \]
Alternative 8
Error3.7
Cost704
\[\frac{\frac{1}{x}}{y + z \cdot \left(y \cdot z\right)} \]
Alternative 9
Error29.5
Cost320
\[\frac{1}{y \cdot x} \]

Error

Reproduce?

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