?

Average Error: 9.88% → 1.95%
Time: 11.6s
Precision: binary64
Cost: 13636

?

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original9.88%
Target8.1%
Herbie1.95%
\[\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 x < -1.02e-98

    1. Initial program 4.21

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

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

      [Start]4.21

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

      associate-/l/ [=>]4.75

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

      associate-*l* [=>]8.24

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

      +-commutative [=>]8.24

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

      fma-def [=>]8.24

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

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

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

      [Start]6.05

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

      associate-/l/ [=>]5.99

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

      associate-/r* [=>]6.04

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

      associate-/r* [=>]5.82

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

      associate-/l* [<=]5.84

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

      *-commutative [<=]5.84

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

      associate-/r* [<=]6.07

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

      associate-/r/ [=>]5.99

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

      /-rgt-identity [=>]5.99

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

      fma-udef [=>]5.99

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

      +-commutative [<=]5.99

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

      hypot-1-def [=>]5.99

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

      fma-udef [=>]5.99

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

      +-commutative [<=]5.99

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

      hypot-1-def [=>]2.91

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

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

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

      [Start]2.11

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

      associate-*r/ [=>]0.43

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

      associate-*r/ [=>]0.36

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

      associate-*l/ [<=]0.36

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

      associate-*r/ [<=]0.37

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

      associate-/r* [<=]2.33

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

      associate-/l/ [=>]2.63

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

      associate-*r* [<=]1.74

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

      *-commutative [<=]1.74

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

      associate-*l/ [=>]1.73

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

      *-lft-identity [=>]1.73

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

      associate-*r* [=>]0.68

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

      *-commutative [<=]0.68

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

      *-commutative [=>]0.68

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

    if -1.02e-98 < x

    1. Initial program 17.78

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

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

      [Start]17.78

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

      associate-/l/ [=>]17.99

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

      associate-*l* [=>]14.14

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

      +-commutative [=>]14.14

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

      fma-def [=>]14.14

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

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

      \[\leadsto \frac{1}{y \cdot \left(\color{blue}{{z}^{2} \cdot x} + x\right)} \]
    5. Simplified3.74

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

      [Start]14.14

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

      unpow2 [=>]14.14

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

      associate-*l* [=>]3.74

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

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

Alternatives

Alternative 1
Error3.06%
Cost13769
\[\begin{array}{l} \mathbf{if}\;z \leq -2.2 \cdot 10^{+15} \lor \neg \left(z \leq 4.4 \cdot 10^{+169}\right):\\ \;\;\;\;\frac{\frac{1}{x \cdot z}}{z \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{\mathsf{hypot}\left(1, z\right) \cdot \left(x \cdot y\right)}}{\mathsf{hypot}\left(1, z\right)}\\ \end{array} \]
Alternative 2
Error3.27%
Cost13636
\[\begin{array}{l} \mathbf{if}\;z \leq 1.12 \cdot 10^{+21}:\\ \;\;\;\;\frac{1}{\left(\mathsf{hypot}\left(1, z\right) \cdot y\right) \cdot \left(x \cdot \mathsf{hypot}\left(1, z\right)\right)}\\ \mathbf{elif}\;z \leq 2.25 \cdot 10^{+170}:\\ \;\;\;\;\frac{\frac{1}{z}}{z \cdot \left(x \cdot y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x \cdot z}}{z \cdot y}\\ \end{array} \]
Alternative 3
Error1.82%
Cost1736
\[\begin{array}{l} t_0 := y \cdot \left(1 + z \cdot z\right)\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(z \cdot y\right)\right)}\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+307}:\\ \;\;\;\;\frac{\frac{1}{x}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x \cdot z}}{z \cdot y}\\ \end{array} \]
Alternative 4
Error6.82%
Cost972
\[\begin{array}{l} t_0 := \frac{1}{x \cdot \left(z \cdot \left(z \cdot y\right)\right)}\\ \mathbf{if}\;z \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 7.1 \cdot 10^{-9}:\\ \;\;\;\;\frac{\frac{1}{x}}{y}\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{+76}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y \cdot \left(z \cdot \left(x \cdot z\right)\right)}\\ \end{array} \]
Alternative 5
Error2.87%
Cost969
\[\begin{array}{l} \mathbf{if}\;z \leq -7 \cdot 10^{+108} \lor \neg \left(z \leq 110000000\right):\\ \;\;\;\;\frac{1}{z \cdot \left(x \cdot \left(z \cdot y\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y \cdot \left(x + x \cdot \left(z \cdot z\right)\right)}\\ \end{array} \]
Alternative 6
Error3.77%
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;\frac{1}{\left(x \cdot z\right) \cdot \left(z \cdot y\right)}\\ \mathbf{elif}\;z \leq 7.1 \cdot 10^{-9}:\\ \;\;\;\;\frac{\frac{1}{x}}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z \cdot \left(x \cdot \left(z \cdot y\right)\right)}\\ \end{array} \]
Alternative 7
Error7.54%
Cost836
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 10^{-20}:\\ \;\;\;\;\frac{\frac{1}{x}}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(z \cdot y\right)\right)}\\ \end{array} \]
Alternative 8
Error4.12%
Cost836
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 10^{-20}:\\ \;\;\;\;\frac{\frac{1}{x}}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z \cdot \left(x \cdot \left(z \cdot y\right)\right)}\\ \end{array} \]
Alternative 9
Error44.73%
Cost320
\[\frac{1}{x \cdot y} \]

Error

Reproduce?

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