Average Error: 6.5 → 2.1
Time: 23.7s
Precision: binary64
Cost: 968
\[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
\[\begin{array}{l} t_0 := \frac{\frac{1}{y}}{\left(x \cdot z\right) \cdot z + x}\\ \mathbf{if}\;y \leq -2.3 \cdot 10^{-137}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-239}:\\ \;\;\;\;\frac{\frac{1}{x}}{\left(y \cdot z\right) \cdot z + y}\\ \mathbf{else}:\\ \;\;\;\;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 y) (+ (* (* x z) z) x))))
   (if (<= y -2.3e-137)
     t_0
     (if (<= y 2.1e-239) (/ (/ 1.0 x) (+ (* (* y z) z) y)) 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 / y) / (((x * z) * z) + x);
	double tmp;
	if (y <= -2.3e-137) {
		tmp = t_0;
	} else if (y <= 2.1e-239) {
		tmp = (1.0 / x) / (((y * z) * z) + y);
	} else {
		tmp = 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 / y) / (((x * z) * z) + x)
    if (y <= (-2.3d-137)) then
        tmp = t_0
    else if (y <= 2.1d-239) then
        tmp = (1.0d0 / x) / (((y * z) * z) + y)
    else
        tmp = 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 / y) / (((x * z) * z) + x);
	double tmp;
	if (y <= -2.3e-137) {
		tmp = t_0;
	} else if (y <= 2.1e-239) {
		tmp = (1.0 / x) / (((y * z) * z) + y);
	} else {
		tmp = 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 / y) / (((x * z) * z) + x)
	tmp = 0
	if y <= -2.3e-137:
		tmp = t_0
	elif y <= 2.1e-239:
		tmp = (1.0 / x) / (((y * z) * z) + y)
	else:
		tmp = 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(Float64(1.0 / y) / Float64(Float64(Float64(x * z) * z) + x))
	tmp = 0.0
	if (y <= -2.3e-137)
		tmp = t_0;
	elseif (y <= 2.1e-239)
		tmp = Float64(Float64(1.0 / x) / Float64(Float64(Float64(y * z) * z) + y));
	else
		tmp = 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 / y) / (((x * z) * z) + x);
	tmp = 0.0;
	if (y <= -2.3e-137)
		tmp = t_0;
	elseif (y <= 2.1e-239)
		tmp = (1.0 / x) / (((y * z) * z) + y);
	else
		tmp = 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[(N[(1.0 / y), $MachinePrecision] / N[(N[(N[(x * z), $MachinePrecision] * z), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.3e-137], t$95$0, If[LessEqual[y, 2.1e-239], N[(N[(1.0 / x), $MachinePrecision] / N[(N[(N[(y * z), $MachinePrecision] * z), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\begin{array}{l}
t_0 := \frac{\frac{1}{y}}{\left(x \cdot z\right) \cdot z + x}\\
\mathbf{if}\;y \leq -2.3 \cdot 10^{-137}:\\
\;\;\;\;t_0\\

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.5
Target5.9
Herbie2.1
\[\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 y < -2.30000000000000008e-137 or 2.1000000000000002e-239 < y

    1. Initial program 5.4

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

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

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

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

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

    if -2.30000000000000008e-137 < y < 2.1000000000000002e-239

    1. Initial program 12.4

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

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

Alternatives

Alternative 1
Error1.9
Cost968
\[\begin{array}{l} t_0 := \frac{1}{y \cdot \left(z \cdot \left(x \cdot z\right) + x\right)}\\ \mathbf{if}\;y \leq -2 \cdot 10^{-137}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4 \cdot 10^{-17}:\\ \;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(z \cdot y\right) + y\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error1.8
Cost832
\[\frac{1}{\left(\left(z \cdot y\right) \cdot x\right) \cdot z + x \cdot y} \]
Alternative 3
Error1.9
Cost832
\[\frac{1}{\left(z \cdot y\right) \cdot \left(z \cdot x\right) + x \cdot y} \]
Alternative 4
Error1.9
Cost832
\[\frac{1}{\left(\left(x \cdot z\right) \cdot y\right) \cdot z + x \cdot y} \]
Alternative 5
Error4.0
Cost704
\[\frac{1}{x \cdot \left(z \cdot \left(z \cdot y\right) + y\right)} \]
Alternative 6
Error17.1
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -9.8 \cdot 10^{+88}:\\ \;\;\;\;9 - 9\\ \mathbf{elif}\;z \leq 520000000:\\ \;\;\;\;\frac{1}{y \cdot x}\\ \mathbf{else}:\\ \;\;\;\;9 - 9\\ \end{array} \]
Alternative 7
Error16.9
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -9.8 \cdot 10^{+88}:\\ \;\;\;\;9 - 9\\ \mathbf{elif}\;z \leq 700000000:\\ \;\;\;\;\frac{\frac{1}{x}}{y}\\ \mathbf{else}:\\ \;\;\;\;9 - 9\\ \end{array} \]
Alternative 8
Error16.9
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -9.8 \cdot 10^{+88}:\\ \;\;\;\;9 - 9\\ \mathbf{elif}\;z \leq 410000000:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;9 - 9\\ \end{array} \]
Alternative 9
Error41.0
Cost192
\[9 - 9 \]

Error

Reproduce

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