?

Average Error: 10% → 3.15%
Time: 9.5s
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} t_0 := y \cdot \left(z \cdot x\right)\\ \mathbf{if}\;z \leq -9.5 \cdot 10^{+153}:\\ \;\;\;\;\frac{\frac{1}{z}}{t_0}\\ \mathbf{elif}\;z \leq 2.55 \cdot 10^{+150}:\\ \;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z \cdot t_0}\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (* z x))))
   (if (<= z -9.5e+153)
     (/ (/ 1.0 z) t_0)
     (if (<= z 2.55e+150)
       (/ (/ 1.0 x) (* y (+ 1.0 (* z z))))
       (/ 1.0 (* z t_0))))))
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 t_0 = y * (z * x);
	double tmp;
	if (z <= -9.5e+153) {
		tmp = (1.0 / z) / t_0;
	} else if (z <= 2.55e+150) {
		tmp = (1.0 / x) / (y * (1.0 + (z * z)));
	} else {
		tmp = 1.0 / (z * t_0);
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = y * (z * x)
    if (z <= (-9.5d+153)) then
        tmp = (1.0d0 / z) / t_0
    else if (z <= 2.55d+150) then
        tmp = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
    else
        tmp = 1.0d0 / (z * t_0)
    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 t_0 = y * (z * x);
	double tmp;
	if (z <= -9.5e+153) {
		tmp = (1.0 / z) / t_0;
	} else if (z <= 2.55e+150) {
		tmp = (1.0 / x) / (y * (1.0 + (z * z)));
	} else {
		tmp = 1.0 / (z * t_0);
	}
	return tmp;
}
def code(x, y, z):
	return (1.0 / x) / (y * (1.0 + (z * z)))
def code(x, y, z):
	t_0 = y * (z * x)
	tmp = 0
	if z <= -9.5e+153:
		tmp = (1.0 / z) / t_0
	elif z <= 2.55e+150:
		tmp = (1.0 / x) / (y * (1.0 + (z * z)))
	else:
		tmp = 1.0 / (z * t_0)
	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)
	t_0 = Float64(y * Float64(z * x))
	tmp = 0.0
	if (z <= -9.5e+153)
		tmp = Float64(Float64(1.0 / z) / t_0);
	elseif (z <= 2.55e+150)
		tmp = Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z))));
	else
		tmp = Float64(1.0 / Float64(z * t_0));
	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)
	t_0 = y * (z * x);
	tmp = 0.0;
	if (z <= -9.5e+153)
		tmp = (1.0 / z) / t_0;
	elseif (z <= 2.55e+150)
		tmp = (1.0 / x) / (y * (1.0 + (z * z)));
	else
		tmp = 1.0 / (z * t_0);
	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_] := Block[{t$95$0 = N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -9.5e+153], N[(N[(1.0 / z), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[z, 2.55e+150], N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(z * t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\begin{array}{l}
t_0 := y \cdot \left(z \cdot x\right)\\
\mathbf{if}\;z \leq -9.5 \cdot 10^{+153}:\\
\;\;\;\;\frac{\frac{1}{z}}{t_0}\\

\mathbf{elif}\;z \leq 2.55 \cdot 10^{+150}:\\
\;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{z \cdot t_0}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10%
Target7.76%
Herbie3.15%
\[\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 < -9.4999999999999995e153

    1. Initial program 27.23

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

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

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

      [Start]27.23

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

      associate-/r* [=>]27.23

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

      *-commutative [=>]27.23

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

      associate-/r* [=>]27.73

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

      associate-/r* [<=]27.73

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

      unpow2 [=>]27.73

      \[ \frac{\frac{1}{y \cdot x}}{\color{blue}{z \cdot z}} \]
    4. Applied egg-rr12.19

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

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

    if -9.4999999999999995e153 < z < 2.55000000000000005e150

    1. Initial program 3.42

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

    if 2.55000000000000005e150 < z

    1. Initial program 27.79

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

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

      [Start]27.79

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

      associate-/l/ [=>]27.79

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

      associate-*l* [=>]27.79

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

      +-commutative [=>]27.79

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

      fma-def [=>]27.79

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

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

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

      [Start]27.79

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

      *-commutative [=>]27.79

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

      unpow2 [=>]27.79

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

      associate-*r* [=>]28.44

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

      *-commutative [=>]28.44

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

      associate-*l* [=>]13.48

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -9.5 \cdot 10^{+153}:\\ \;\;\;\;\frac{\frac{1}{z}}{y \cdot \left(z \cdot x\right)}\\ \mathbf{elif}\;z \leq 2.55 \cdot 10^{+150}:\\ \;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z \cdot \left(y \cdot \left(z \cdot x\right)\right)}\\ \end{array} \]

Alternatives

Alternative 1
Error3.22%
Cost968
\[\begin{array}{l} \mathbf{if}\;z \leq -1.45 \cdot 10^{+152}:\\ \;\;\;\;\frac{\frac{1}{z}}{y \cdot \left(z \cdot x\right)}\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{+66}:\\ \;\;\;\;\frac{1}{y \cdot \left(x + x \cdot \left(z \cdot z\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(z \cdot x\right) \cdot \left(z \cdot y\right)}\\ \end{array} \]
Alternative 2
Error3.52%
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \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 3
Error3.67%
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\ \;\;\;\;\frac{1}{\left(z \cdot x\right) \cdot \left(z \cdot y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \end{array} \]
Alternative 4
Error3.57%
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;\frac{1}{z \cdot x} \cdot \frac{1}{z \cdot y}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(z \cdot x\right) \cdot \left(z \cdot y\right)}\\ \end{array} \]
Alternative 5
Error45.14%
Cost320
\[\frac{1}{y \cdot x} \]
Alternative 6
Error45.08%
Cost320
\[\frac{\frac{1}{x}}{y} \]
Alternative 7
Error45.09%
Cost320
\[\frac{\frac{1}{y}}{x} \]

Error

Reproduce?

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