?

Average Error: 6.5 → 5.1
Time: 24.5s
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} \mathbf{if}\;y \leq 5 \cdot 10^{-33}:\\ \;\;\;\;\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} \]
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
(FPCore (x y z)
 :precision binary64
 (if (<= y 5e-33)
   (/ (/ 1.0 x) (* y (+ 1.0 (* z z))))
   (/ (/ -1.0 y) (* x (- -1.0 (* z 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 (y <= 5e-33) {
		tmp = (1.0 / x) / (y * (1.0 + (z * z)));
	} else {
		tmp = (-1.0 / y) / (x * (-1.0 - (z * 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 (y <= 5d-33) then
        tmp = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
    else
        tmp = ((-1.0d0) / y) / (x * ((-1.0d0) - (z * 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 (y <= 5e-33) {
		tmp = (1.0 / x) / (y * (1.0 + (z * z)));
	} else {
		tmp = (-1.0 / y) / (x * (-1.0 - (z * 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 y <= 5e-33:
		tmp = (1.0 / x) / (y * (1.0 + (z * z)))
	else:
		tmp = (-1.0 / y) / (x * (-1.0 - (z * 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 (y <= 5e-33)
		tmp = Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z))));
	else
		tmp = Float64(Float64(-1.0 / y) / Float64(x * Float64(-1.0 - Float64(z * 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 (y <= 5e-33)
		tmp = (1.0 / x) / (y * (1.0 + (z * z)));
	else
		tmp = (-1.0 / y) / (x * (-1.0 - (z * 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[y, 5e-33], N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 / y), $MachinePrecision] / N[(x * N[(-1.0 - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{-33}:\\
\;\;\;\;\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}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.5
Target5.1
Herbie5.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 < 5.00000000000000028e-33

    1. Initial program 8.4

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

    if 5.00000000000000028e-33 < y

    1. Initial program 4.6

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

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

      [Start]4.6

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

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

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

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

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

      [Start]2.2

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

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

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

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

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

      rational.json-simplify-44 [=>]4.4

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

      rational.json-simplify-44 [<=]2.0

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 5 \cdot 10^{-33}:\\ \;\;\;\;\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
Cost904
\[\begin{array}{l} t_0 := -1 + \left(1 - \frac{\frac{1}{x}}{-y}\right)\\ \mathbf{if}\;z \leq -4.6 \cdot 10^{+18}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 6.8 \cdot 10^{+34}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error5.4
Cost836
\[\begin{array}{l} t_0 := 1 + z \cdot z\\ \mathbf{if}\;y \leq 10^{+15}:\\ \;\;\;\;\frac{1}{x \cdot \left(y \cdot t_0\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y \cdot \left(x \cdot t_0\right)}\\ \end{array} \]
Alternative 3
Error5.2
Cost836
\[\begin{array}{l} \mathbf{if}\;y \leq 0.5:\\ \;\;\;\;\frac{1}{x \cdot \left(y \cdot \left(1 + z \cdot z\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-1}{y}}{x \cdot \left(-1 - z \cdot z\right)}\\ \end{array} \]
Alternative 4
Error26.4
Cost712
\[\begin{array}{l} t_0 := \frac{x}{x \cdot \left(x \cdot y\right)}\\ \mathbf{if}\;z \leq -1.12 \cdot 10^{+20}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{+103}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error25.9
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -3.4 \cdot 10^{+50}:\\ \;\;\;\;\frac{x}{y \cdot \left(x \cdot x\right)}\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{+105}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x \cdot \left(x \cdot y\right)}\\ \end{array} \]
Alternative 6
Error25.8
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -7.1 \cdot 10^{+62}:\\ \;\;\;\;\frac{y}{x \cdot \left(y \cdot y\right)}\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{+106}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x \cdot \left(x \cdot y\right)}\\ \end{array} \]
Alternative 7
Error6.6
Cost704
\[\frac{1}{x \cdot \left(y \cdot \left(1 + z \cdot z\right)\right)} \]
Alternative 8
Error29.2
Cost320
\[\frac{1}{y \cdot x} \]
Alternative 9
Error29.3
Cost320
\[\frac{\frac{1}{x}}{y} \]
Alternative 10
Error29.3
Cost320
\[\frac{\frac{1}{y}}{x} \]

Error

Reproduce?

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