?

Average Error: 6.2 → 4.9
Time: 27.1s
Precision: binary64
Cost: 836

?

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.2
Target4.8
Herbie4.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 2 regimes
  2. if x < -1.49999999999999998e84

    1. Initial program 0.8

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

    if -1.49999999999999998e84 < x

    1. Initial program 9.1

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

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

      [Start]9.1

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

      rational.json-simplify-46 [=>]9.3

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

      \[\leadsto \color{blue}{\frac{\frac{\frac{1}{y}}{1 + z \cdot z}}{x} + 0} \]
    4. Simplified7.2

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

      [Start]8.9

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

      rational.json-simplify-4 [=>]8.9

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

      rational.json-simplify-47 [=>]7.2

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

      rational.json-simplify-2 [<=]7.2

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

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

Alternatives

Alternative 1
Error20.4
Cost840
\[\begin{array}{l} t_0 := -1 + \left(1 - \frac{\frac{-1}{y}}{x}\right)\\ \mathbf{if}\;z \leq -1.35 \cdot 10^{+45}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 24000000000:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error20.4
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -1.35 \cdot 10^{+45}:\\ \;\;\;\;-1 + \left(1 - \frac{\frac{-1}{y}}{x}\right)\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{+15}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;1 - \left(1 + \frac{-1}{y \cdot x}\right)\\ \end{array} \]
Alternative 3
Error5.0
Cost836
\[\begin{array}{l} t_0 := 1 + z \cdot z\\ \mathbf{if}\;y \leq 2 \cdot 10^{-50}:\\ \;\;\;\;\frac{1}{x \cdot \left(y \cdot t_0\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{t_0 \cdot \left(x \cdot y\right)}\\ \end{array} \]
Alternative 4
Error4.9
Cost836
\[\begin{array}{l} t_0 := 1 + z \cdot z\\ \mathbf{if}\;y \leq 1.25 \cdot 10^{-47}:\\ \;\;\;\;\frac{\frac{1}{x}}{y \cdot t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{t_0 \cdot \left(x \cdot y\right)}\\ \end{array} \]
Alternative 5
Error25.6
Cost712
\[\begin{array}{l} t_0 := \frac{x}{x \cdot \left(x \cdot y\right)}\\ \mathbf{if}\;z \leq -1.6 \cdot 10^{+65}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.65 \cdot 10^{+14}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error25.4
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -2.7 \cdot 10^{+65}:\\ \;\;\;\;\frac{y}{y \cdot \left(y \cdot x\right)}\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{+15}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x \cdot \left(x \cdot y\right)}\\ \end{array} \]
Alternative 7
Error6.3
Cost704
\[\frac{1}{x \cdot \left(y \cdot \left(1 + z \cdot z\right)\right)} \]
Alternative 8
Error28.6
Cost320
\[\frac{1}{y \cdot x} \]

Error

Reproduce?

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