Average Error: 6.2 → 1.9
Time: 7.6s
Precision: binary64
Cost: 968
\[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
\[\begin{array}{l} \mathbf{if}\;z \leq -1.327367518792495 \cdot 10^{+137}:\\ \;\;\;\;\frac{1}{z} \cdot \frac{\frac{1}{y}}{z \cdot x}\\ \mathbf{elif}\;z \leq 3.9760885107790073 \cdot 10^{+33}:\\ \;\;\;\;\frac{\frac{-1}{y \cdot x}}{-1 - z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z \cdot \left(x \cdot \left(z \cdot y\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 (<= z -1.327367518792495e+137)
   (* (/ 1.0 z) (/ (/ 1.0 y) (* z x)))
   (if (<= z 3.9760885107790073e+33)
     (/ (/ -1.0 (* y x)) (- -1.0 (* z z)))
     (/ 1.0 (* z (* x (* z y)))))))
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.327367518792495e+137) {
		tmp = (1.0 / z) * ((1.0 / y) / (z * x));
	} else if (z <= 3.9760885107790073e+33) {
		tmp = (-1.0 / (y * x)) / (-1.0 - (z * z));
	} else {
		tmp = 1.0 / (z * (x * (z * y)));
	}
	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.327367518792495d+137)) then
        tmp = (1.0d0 / z) * ((1.0d0 / y) / (z * x))
    else if (z <= 3.9760885107790073d+33) then
        tmp = ((-1.0d0) / (y * x)) / ((-1.0d0) - (z * z))
    else
        tmp = 1.0d0 / (z * (x * (z * y)))
    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.327367518792495e+137) {
		tmp = (1.0 / z) * ((1.0 / y) / (z * x));
	} else if (z <= 3.9760885107790073e+33) {
		tmp = (-1.0 / (y * x)) / (-1.0 - (z * z));
	} else {
		tmp = 1.0 / (z * (x * (z * y)));
	}
	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.327367518792495e+137:
		tmp = (1.0 / z) * ((1.0 / y) / (z * x))
	elif z <= 3.9760885107790073e+33:
		tmp = (-1.0 / (y * x)) / (-1.0 - (z * z))
	else:
		tmp = 1.0 / (z * (x * (z * y)))
	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.327367518792495e+137)
		tmp = Float64(Float64(1.0 / z) * Float64(Float64(1.0 / y) / Float64(z * x)));
	elseif (z <= 3.9760885107790073e+33)
		tmp = Float64(Float64(-1.0 / Float64(y * x)) / Float64(-1.0 - Float64(z * z)));
	else
		tmp = Float64(1.0 / Float64(z * Float64(x * Float64(z * y))));
	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.327367518792495e+137)
		tmp = (1.0 / z) * ((1.0 / y) / (z * x));
	elseif (z <= 3.9760885107790073e+33)
		tmp = (-1.0 / (y * x)) / (-1.0 - (z * z));
	else
		tmp = 1.0 / (z * (x * (z * y)));
	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.327367518792495e+137], N[(N[(1.0 / z), $MachinePrecision] * N[(N[(1.0 / y), $MachinePrecision] / N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.9760885107790073e+33], N[(N[(-1.0 / N[(y * x), $MachinePrecision]), $MachinePrecision] / N[(-1.0 - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(z * N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\begin{array}{l}
\mathbf{if}\;z \leq -1.327367518792495 \cdot 10^{+137}:\\
\;\;\;\;\frac{1}{z} \cdot \frac{\frac{1}{y}}{z \cdot x}\\

\mathbf{elif}\;z \leq 3.9760885107790073 \cdot 10^{+33}:\\
\;\;\;\;\frac{\frac{-1}{y \cdot x}}{-1 - z \cdot z}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.2
Target5.6
Herbie1.9
\[\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.32736751879249503e137

    1. Initial program 17.0

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

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

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

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

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

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

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

    if -1.32736751879249503e137 < z < 3.9760885107790073e33

    1. Initial program 1.2

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

      \[\leadsto \color{blue}{\sqrt[3]{{\left(x \cdot \mathsf{fma}\left(y, z \cdot z, y\right)\right)}^{-3}}} \]
    3. Taylor expanded in y around -inf 1.4

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

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

    if 3.9760885107790073e33 < z

    1. Initial program 12.8

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

      \[\leadsto \color{blue}{\sqrt[3]{{\left(x \cdot \mathsf{fma}\left(y, z \cdot z, y\right)\right)}^{-3}}} \]
    3. Taylor expanded in y around -inf 13.6

      \[\leadsto \color{blue}{\frac{-1}{\left(-1 \cdot {z}^{2} - 1\right) \cdot \left(y \cdot x\right)}} \]
    4. Simplified13.5

      \[\leadsto \color{blue}{\frac{\frac{-1}{y \cdot x}}{-1 - z \cdot z}} \]
    5. Taylor expanded in z around inf 13.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.327367518792495 \cdot 10^{+137}:\\ \;\;\;\;\frac{1}{z} \cdot \frac{\frac{1}{y}}{z \cdot x}\\ \mathbf{elif}\;z \leq 3.9760885107790073 \cdot 10^{+33}:\\ \;\;\;\;\frac{\frac{-1}{y \cdot x}}{-1 - z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z \cdot \left(x \cdot \left(z \cdot y\right)\right)}\\ \end{array} \]

Alternatives

Alternative 1
Error4.2
Cost840
\[\begin{array}{l} t_0 := \frac{\frac{1}{x}}{z \cdot \left(z \cdot y\right)}\\ \mathbf{if}\;z \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error2.4
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;\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}{z \cdot \left(x \cdot \left(z \cdot y\right)\right)}\\ \end{array} \]
Alternative 3
Error2.4
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;\frac{1}{z} \cdot \frac{\frac{1}{y}}{z \cdot x}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z \cdot \left(x \cdot \left(z \cdot y\right)\right)}\\ \end{array} \]
Alternative 4
Error2.3
Cost836
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 0.2:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z \cdot \left(x \cdot \left(z \cdot y\right)\right)}\\ \end{array} \]
Alternative 5
Error28.0
Cost320
\[\frac{\frac{1}{y}}{x} \]

Error

Reproduce

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