?

Average Error: 10.15% → 4.03%
Time: 13.1s
Precision: binary64
Cost: 968

?

\[ \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}\;z \leq -4.5 \cdot 10^{+179}:\\ \;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(z \cdot y\right)}\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{+31}:\\ \;\;\;\;\frac{\frac{\frac{1}{x}}{y}}{1 + z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y \cdot \left(z \cdot x\right)}}{z}\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
(FPCore (x y z)
 :precision binary64
 (if (<= z -4.5e+179)
   (/ (/ 1.0 z) (* x (* z y)))
   (if (<= z 1.55e+31)
     (/ (/ (/ 1.0 x) y) (+ 1.0 (* z z)))
     (/ (/ 1.0 (* y (* 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 (z <= -4.5e+179) {
		tmp = (1.0 / z) / (x * (z * y));
	} else if (z <= 1.55e+31) {
		tmp = ((1.0 / x) / y) / (1.0 + (z * z));
	} else {
		tmp = (1.0 / (y * (z * x))) / z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
end function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-4.5d+179)) then
        tmp = (1.0d0 / z) / (x * (z * y))
    else if (z <= 1.55d+31) then
        tmp = ((1.0d0 / x) / y) / (1.0d0 + (z * z))
    else
        tmp = (1.0d0 / (y * (z * x))) / z
    end if
    code = tmp
end function
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 (z <= -4.5e+179) {
		tmp = (1.0 / z) / (x * (z * y));
	} else if (z <= 1.55e+31) {
		tmp = ((1.0 / x) / y) / (1.0 + (z * z));
	} else {
		tmp = (1.0 / (y * (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 z <= -4.5e+179:
		tmp = (1.0 / z) / (x * (z * y))
	elif z <= 1.55e+31:
		tmp = ((1.0 / x) / y) / (1.0 + (z * z))
	else:
		tmp = (1.0 / (y * (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 (z <= -4.5e+179)
		tmp = Float64(Float64(1.0 / z) / Float64(x * Float64(z * y)));
	elseif (z <= 1.55e+31)
		tmp = Float64(Float64(Float64(1.0 / x) / y) / Float64(1.0 + Float64(z * z)));
	else
		tmp = Float64(Float64(1.0 / Float64(y * Float64(z * 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 (z <= -4.5e+179)
		tmp = (1.0 / z) / (x * (z * y));
	elseif (z <= 1.55e+31)
		tmp = ((1.0 / x) / y) / (1.0 + (z * z));
	else
		tmp = (1.0 / (y * (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[z, -4.5e+179], N[(N[(1.0 / z), $MachinePrecision] / N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.55e+31], N[(N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision] / N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\begin{array}{l}
\mathbf{if}\;z \leq -4.5 \cdot 10^{+179}:\\
\;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(z \cdot y\right)}\\

\mathbf{elif}\;z \leq 1.55 \cdot 10^{+31}:\\
\;\;\;\;\frac{\frac{\frac{1}{x}}{y}}{1 + z \cdot z}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10.15%
Target8.1%
Herbie4.03%
\[\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 z < -4.5000000000000003e179

    1. Initial program 27.17

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

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

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

      [Start]27.17

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

      *-commutative [=>]27.17

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

      associate-/r* [=>]27.17

      \[ \color{blue}{\frac{\frac{1}{{z}^{2} \cdot x}}{y}} \]

      unpow2 [=>]27.17

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

      associate-*l* [=>]12.96

      \[ \frac{\frac{1}{\color{blue}{z \cdot \left(z \cdot x\right)}}}{y} \]
    4. Applied egg-rr2.07

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

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

    if -4.5000000000000003e179 < z < 1.5500000000000001e31

    1. Initial program 3.83

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

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

      [Start]3.83

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

      associate-/r* [=>]3.91

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

    if 1.5500000000000001e31 < z

    1. Initial program 18.92

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

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

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

      [Start]18.05

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

      *-commutative [=>]18.05

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

      associate-/r* [=>]17.75

      \[ \color{blue}{\frac{\frac{1}{{z}^{2} \cdot x}}{y}} \]

      unpow2 [=>]17.75

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

      associate-*l* [=>]9.78

      \[ \frac{\frac{1}{\color{blue}{z \cdot \left(z \cdot x\right)}}}{y} \]
    4. Applied egg-rr4.12

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\left(z \cdot x\right) \cdot y}}{z}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification4.03

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

Alternatives

Alternative 1
Error2.83%
Cost13632
\[\frac{1}{\mathsf{hypot}\left(1, z\right)} \cdot \frac{\frac{1}{x}}{\mathsf{hypot}\left(1, z\right) \cdot y} \]
Alternative 2
Error1.24%
Cost7492
\[\begin{array}{l} \mathbf{if}\;y \cdot \left(1 + z \cdot z\right) \leq 2 \cdot 10^{+305}:\\ \;\;\;\;\frac{\frac{1}{x}}{\mathsf{fma}\left(z \cdot y, z, y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y \cdot \left(z \cdot x\right)}}{z}\\ \end{array} \]
Alternative 3
Error3%
Cost968
\[\begin{array}{l} \mathbf{if}\;z \leq -4 \cdot 10^{+16}:\\ \;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(z \cdot y\right)}\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{+29}:\\ \;\;\;\;\frac{1}{y \cdot \left(x + x \cdot \left(z \cdot z\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y \cdot \left(z \cdot x\right)}}{z}\\ \end{array} \]
Alternative 4
Error2.74%
Cost968
\[\begin{array}{l} \mathbf{if}\;z \leq -4 \cdot 10^{+88}:\\ \;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(z \cdot y\right)}\\ \mathbf{elif}\;z \leq 1.46 \cdot 10^{+29}:\\ \;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y \cdot \left(z \cdot x\right)}}{z}\\ \end{array} \]
Alternative 5
Error4.33%
Cost968
\[\begin{array}{l} \mathbf{if}\;z \leq -4.5 \cdot 10^{+179}:\\ \;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(z \cdot y\right)}\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{+28}:\\ \;\;\;\;\frac{\frac{1}{x \cdot y}}{1 + z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y \cdot \left(z \cdot x\right)}}{z}\\ \end{array} \]
Alternative 6
Error6.54%
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -4300000000:\\ \;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(z \cdot y\right)\right)}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y \cdot \left(z \cdot \left(z \cdot x\right)\right)}\\ \end{array} \]
Alternative 7
Error6.63%
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -4300000000:\\ \;\;\;\;\frac{1}{z \cdot \left(z \cdot \left(x \cdot y\right)\right)}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y \cdot \left(z \cdot \left(z \cdot x\right)\right)}\\ \end{array} \]
Alternative 8
Error6.52%
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -4300000000:\\ \;\;\;\;\frac{1}{z \cdot \left(z \cdot \left(x \cdot y\right)\right)}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y}}{z \cdot \left(z \cdot x\right)}\\ \end{array} \]
Alternative 9
Error3.71%
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -4300000000:\\ \;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(z \cdot y\right)}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y \cdot \left(z \cdot x\right)}}{z}\\ \end{array} \]
Alternative 10
Error7.44%
Cost836
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 2 \cdot 10^{-26}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(z \cdot y\right)\right)}\\ \end{array} \]
Alternative 11
Error4.31%
Cost836
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 2 \cdot 10^{-26}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(z \cdot y\right)}\\ \end{array} \]
Alternative 12
Error45.05%
Cost320
\[\frac{1}{x \cdot y} \]

Error

Reproduce?

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