?

Average Accuracy: 89.9% → 97.0%
Time: 12.6s
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 -1.6 \cdot 10^{+145}:\\ \;\;\;\;\frac{\frac{1}{x \cdot z}}{z \cdot y}\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+129}:\\ \;\;\;\;\frac{\frac{\frac{1}{x}}{y}}{1 + z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-1}{z}}{x} \cdot \frac{\frac{-1}{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 -1.6e+145)
   (/ (/ 1.0 (* x z)) (* z y))
   (if (<= z 2e+129)
     (/ (/ (/ 1.0 x) y) (+ 1.0 (* z z)))
     (* (/ (/ -1.0 z) x) (/ (/ -1.0 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 <= -1.6e+145) {
		tmp = (1.0 / (x * z)) / (z * y);
	} else if (z <= 2e+129) {
		tmp = ((1.0 / x) / y) / (1.0 + (z * z));
	} else {
		tmp = ((-1.0 / z) / x) * ((-1.0 / 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 <= (-1.6d+145)) then
        tmp = (1.0d0 / (x * z)) / (z * y)
    else if (z <= 2d+129) then
        tmp = ((1.0d0 / x) / y) / (1.0d0 + (z * z))
    else
        tmp = (((-1.0d0) / z) / x) * (((-1.0d0) / 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 <= -1.6e+145) {
		tmp = (1.0 / (x * z)) / (z * y);
	} else if (z <= 2e+129) {
		tmp = ((1.0 / x) / y) / (1.0 + (z * z));
	} else {
		tmp = ((-1.0 / z) / x) * ((-1.0 / 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 <= -1.6e+145:
		tmp = (1.0 / (x * z)) / (z * y)
	elif z <= 2e+129:
		tmp = ((1.0 / x) / y) / (1.0 + (z * z))
	else:
		tmp = ((-1.0 / z) / x) * ((-1.0 / 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 (z <= -1.6e+145)
		tmp = Float64(Float64(1.0 / Float64(x * z)) / Float64(z * y));
	elseif (z <= 2e+129)
		tmp = Float64(Float64(Float64(1.0 / x) / y) / Float64(1.0 + Float64(z * z)));
	else
		tmp = Float64(Float64(Float64(-1.0 / z) / x) * Float64(Float64(-1.0 / 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 <= -1.6e+145)
		tmp = (1.0 / (x * z)) / (z * y);
	elseif (z <= 2e+129)
		tmp = ((1.0 / x) / y) / (1.0 + (z * z));
	else
		tmp = ((-1.0 / z) / x) * ((-1.0 / 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[z, -1.6e+145], N[(N[(1.0 / N[(x * z), $MachinePrecision]), $MachinePrecision] / N[(z * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2e+129], N[(N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision] / N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-1.0 / z), $MachinePrecision] / x), $MachinePrecision] * N[(N[(-1.0 / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\begin{array}{l}
\mathbf{if}\;z \leq -1.6 \cdot 10^{+145}:\\
\;\;\;\;\frac{\frac{1}{x \cdot z}}{z \cdot y}\\

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original89.9%
Target92.0%
Herbie97.0%
\[\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 < -1.60000000000000004e145

    1. Initial program 72.3%

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

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

      [Start]72.3

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

      associate-/r* [<=]72.2

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

      +-commutative [=>]72.2

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

      fma-def [=>]72.2

      \[ \frac{1}{x \cdot \left(y \cdot \color{blue}{\mathsf{fma}\left(z, z, 1\right)}\right)} \]
    3. Taylor expanded in z around inf 72.2%

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

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

      [Start]72.2

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

      unpow2 [=>]72.2

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

      *-commutative [=>]72.2

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

      associate-*l* [=>]88.3

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

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

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

      [Start]72.4

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

      associate-*r* [=>]72.2

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

      *-commutative [=>]72.2

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

      unpow2 [=>]72.2

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

      associate-*r* [<=]88.3

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

      associate-/l/ [<=]88.6

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

      associate-/r* [=>]97.7

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

      associate-/r* [<=]97.7

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

      *-commutative [=>]97.7

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

      *-commutative [=>]97.7

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

    if -1.60000000000000004e145 < z < 2e129

    1. Initial program 97.1%

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

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

      [Start]97.1

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

      associate-/r* [=>]97.0

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

    if 2e129 < z

    1. Initial program 74.0%

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

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

      [Start]74.0

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

      associate-/r* [=>]73.6

      \[ \color{blue}{\frac{\frac{\frac{1}{x}}{y}}{1 + z \cdot z}} \]
    3. Applied egg-rr96.4%

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

      [Start]73.6

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

      div-inv [=>]73.6

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

      add-sqr-sqrt [=>]73.6

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

      times-frac [=>]74.2

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

      hypot-1-def [=>]74.2

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

      hypot-1-def [=>]96.4

      \[ \frac{\frac{1}{x}}{\mathsf{hypot}\left(1, z\right)} \cdot \frac{\frac{1}{y}}{\color{blue}{\mathsf{hypot}\left(1, z\right)}} \]
    4. Taylor expanded in z around -inf 67.4%

      \[\leadsto \color{blue}{\frac{-1}{z \cdot x}} \cdot \frac{\frac{1}{y}}{\mathsf{hypot}\left(1, z\right)} \]
    5. Simplified67.4%

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

      [Start]67.4

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

      associate-/r* [=>]67.4

      \[ \color{blue}{\frac{\frac{-1}{z}}{x}} \cdot \frac{\frac{1}{y}}{\mathsf{hypot}\left(1, z\right)} \]
    6. Taylor expanded in z around -inf 96.1%

      \[\leadsto \frac{\frac{-1}{z}}{x} \cdot \color{blue}{\frac{-1}{y \cdot z}} \]
    7. Simplified96.4%

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

      [Start]96.1

      \[ \frac{\frac{-1}{z}}{x} \cdot \frac{-1}{y \cdot z} \]

      associate-/r* [=>]96.4

      \[ \frac{\frac{-1}{z}}{x} \cdot \color{blue}{\frac{\frac{-1}{y}}{z}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification97.0%

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

Alternatives

Alternative 1
Accuracy97.7%
Cost13632
\[\frac{\frac{1}{x}}{\mathsf{hypot}\left(1, z\right)} \cdot \frac{\frac{1}{y}}{\mathsf{hypot}\left(1, z\right)} \]
Alternative 2
Accuracy96.5%
Cost968
\[\begin{array}{l} \mathbf{if}\;z \leq -0.86:\\ \;\;\;\;\frac{1}{y \cdot \left(x \cdot z\right)} \cdot \frac{1}{z}\\ \mathbf{elif}\;z \leq 9.2 \cdot 10^{-10}:\\ \;\;\;\;\frac{\frac{1 - z \cdot z}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-1}{z}}{x} \cdot \frac{\frac{-1}{y}}{z}\\ \end{array} \]
Alternative 3
Accuracy97.5%
Cost968
\[\begin{array}{l} \mathbf{if}\;z \leq -2 \cdot 10^{+14}:\\ \;\;\;\;\frac{1}{y \cdot \left(x \cdot z\right)} \cdot \frac{1}{z}\\ \mathbf{elif}\;z \leq 9200000000:\\ \;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-1}{z}}{x} \cdot \frac{\frac{-1}{y}}{z}\\ \end{array} \]
Alternative 4
Accuracy96.2%
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 9.2 \cdot 10^{-10}\right):\\ \;\;\;\;\frac{1}{z \cdot \left(y \cdot \left(x \cdot z\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \end{array} \]
Alternative 5
Accuracy96.1%
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;\frac{1}{z \cdot \left(y \cdot \left(x \cdot z\right)\right)}\\ \mathbf{elif}\;z \leq 9.2 \cdot 10^{-10}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x \cdot z}}{z \cdot y}\\ \end{array} \]
Alternative 6
Accuracy96.2%
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -0.86:\\ \;\;\;\;\frac{1}{z \cdot \left(y \cdot \left(x \cdot z\right)\right)}\\ \mathbf{elif}\;z \leq 9.2 \cdot 10^{-10}:\\ \;\;\;\;\frac{\frac{1 - z \cdot z}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x \cdot z}}{z \cdot y}\\ \end{array} \]
Alternative 7
Accuracy96.3%
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -0.86:\\ \;\;\;\;\frac{1}{y \cdot \left(x \cdot z\right)} \cdot \frac{1}{z}\\ \mathbf{elif}\;z \leq 9.2 \cdot 10^{-10}:\\ \;\;\;\;\frac{\frac{1 - z \cdot z}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x \cdot z}}{z \cdot y}\\ \end{array} \]
Alternative 8
Accuracy93.5%
Cost836
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 10^{-5}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(z \cdot y\right)\right)}\\ \end{array} \]
Alternative 9
Accuracy67.4%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 8.8 \cdot 10^{+111}\right):\\ \;\;\;\;\frac{-1}{y \cdot \left(x \cdot z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \end{array} \]
Alternative 10
Accuracy55.4%
Cost320
\[\frac{1}{x \cdot y} \]

Error

Reproduce?

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