?

Average Error: 6.4 → 1.8
Time: 12.4s
Precision: binary64
Cost: 1028

?

\[ \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 \cdot z \leq 2 \cdot 10^{+185}:\\ \;\;\;\;\frac{\frac{\frac{-1}{y}}{-x}}{1 + z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{1}{x}}{z \cdot y}}{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 z) 2e+185)
   (/ (/ (/ -1.0 y) (- x)) (+ 1.0 (* z z)))
   (/ (/ (/ 1.0 x) (* z y)) 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 * z) <= 2e+185) {
		tmp = ((-1.0 / y) / -x) / (1.0 + (z * z));
	} else {
		tmp = ((1.0 / x) / (z * y)) / 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 * z) <= 2d+185) then
        tmp = (((-1.0d0) / y) / -x) / (1.0d0 + (z * z))
    else
        tmp = ((1.0d0 / x) / (z * y)) / 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 * z) <= 2e+185) {
		tmp = ((-1.0 / y) / -x) / (1.0 + (z * z));
	} else {
		tmp = ((1.0 / x) / (z * y)) / 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 * z) <= 2e+185:
		tmp = ((-1.0 / y) / -x) / (1.0 + (z * z))
	else:
		tmp = ((1.0 / x) / (z * y)) / 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 (Float64(z * z) <= 2e+185)
		tmp = Float64(Float64(Float64(-1.0 / y) / Float64(-x)) / Float64(1.0 + Float64(z * z)));
	else
		tmp = Float64(Float64(Float64(1.0 / x) / Float64(z * y)) / 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 * z) <= 2e+185)
		tmp = ((-1.0 / y) / -x) / (1.0 + (z * z));
	else
		tmp = ((1.0 / x) / (z * y)) / 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[N[(z * z), $MachinePrecision], 2e+185], N[(N[(N[(-1.0 / y), $MachinePrecision] / (-x)), $MachinePrecision] / N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / x), $MachinePrecision] / N[(z * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+185}:\\
\;\;\;\;\frac{\frac{\frac{-1}{y}}{-x}}{1 + z \cdot z}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{1}{x}}{z \cdot y}}{z}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.4
Target5.0
Herbie1.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 z z) < 2e185

    1. Initial program 1.1

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

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

      [Start]1.1

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

      associate-/r* [=>]1.2

      \[ \color{blue}{\frac{\frac{\frac{1}{x}}{y}}{1 + z \cdot z}} \]
    3. Applied egg-rr1.2

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

    if 2e185 < (*.f64 z z)

    1. Initial program 15.4

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

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

      [Start]15.4

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

      associate-/r* [=>]15.3

      \[ \color{blue}{\frac{\frac{\frac{1}{x}}{y}}{1 + z \cdot z}} \]
    3. Applied egg-rr2.7

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

      \[\leadsto \color{blue}{\frac{\frac{\frac{1}{x}}{\mathsf{hypot}\left(1, z\right)}}{\mathsf{hypot}\left(1, z\right) \cdot y}} \]
    5. Taylor expanded in z around inf 15.4

      \[\leadsto \color{blue}{\frac{1}{y \cdot \left({z}^{2} \cdot x\right)}} \]
    6. Simplified7.9

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

      [Start]15.4

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

      unpow2 [=>]15.4

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

      associate-*l* [=>]7.9

      \[ \frac{1}{y \cdot \color{blue}{\left(z \cdot \left(z \cdot x\right)\right)}} \]
    7. Taylor expanded in y around 0 15.4

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

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

      [Start]15.4

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

      associate-/r* [=>]15.2

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

      unpow2 [=>]15.2

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

      associate-*r* [<=]7.7

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

      associate-/l/ [<=]2.8

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

      associate-/l/ [=>]2.8

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

      associate-/r* [=>]2.8

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

      associate-/l/ [<=]2.7

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

      associate-/l/ [=>]2.7

      \[ \frac{\color{blue}{\frac{\frac{1}{x}}{y \cdot z}}}{z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+185}:\\ \;\;\;\;\frac{\frac{\frac{-1}{y}}{-x}}{1 + z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{1}{x}}{z \cdot y}}{z}\\ \end{array} \]

Alternatives

Alternative 1
Error1.6
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.4
Cost13504
\[\frac{\frac{\frac{1}{x}}{\mathsf{hypot}\left(1, z\right)}}{\mathsf{hypot}\left(1, z\right) \cdot y} \]
Alternative 3
Error1.8
Cost969
\[\begin{array}{l} \mathbf{if}\;z \leq -2.8 \cdot 10^{+37} \lor \neg \left(z \leq 6.6 \cdot 10^{+30}\right):\\ \;\;\;\;\frac{\frac{\frac{1}{x}}{z \cdot y}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y \cdot \left(x + x \cdot \left(z \cdot z\right)\right)}\\ \end{array} \]
Alternative 4
Error1.6
Cost969
\[\begin{array}{l} \mathbf{if}\;z \leq -1.6 \cdot 10^{+45} \lor \neg \left(z \leq 92000000\right):\\ \;\;\;\;\frac{\frac{\frac{1}{x}}{z \cdot y}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\ \end{array} \]
Alternative 5
Error1.7
Cost968
\[\begin{array}{l} \mathbf{if}\;z \leq -2 \cdot 10^{+95}:\\ \;\;\;\;\frac{\frac{\frac{1}{x}}{z \cdot y}}{z}\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{+90}:\\ \;\;\;\;\frac{\frac{\frac{1}{x}}{y}}{1 + z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{z \cdot x}}{z \cdot y}\\ \end{array} \]
Alternative 6
Error4.6
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -62000000000000 \lor \neg \left(z \leq 1\right):\\ \;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(z \cdot y\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \end{array} \]
Alternative 7
Error2.7
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -62000000000000 \lor \neg \left(z \leq 1\right):\\ \;\;\;\;\frac{1}{z \cdot \left(y \cdot \left(z \cdot x\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \end{array} \]
Alternative 8
Error4.7
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -62000000000000:\\ \;\;\;\;\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 9
Error2.6
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -62000000000000:\\ \;\;\;\;\frac{1}{z \cdot \left(y \cdot \left(z \cdot x\right)\right)}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(z \cdot y\right) \cdot \left(z \cdot x\right)}\\ \end{array} \]
Alternative 10
Error2.0
Cost836
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 2 \cdot 10^{-5}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{z \cdot x}}{z \cdot y}\\ \end{array} \]
Alternative 11
Error2.1
Cost836
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 2 \cdot 10^{-5}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{1}{x}}{z \cdot y}}{z}\\ \end{array} \]
Alternative 12
Error28.3
Cost320
\[\frac{1}{x \cdot y} \]

Error

Reproduce?

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