?

Average Error: 6.5 → 5.2
Time: 28.8s
Precision: binary64
Cost: 8584

?

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

\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;\frac{1}{\left({z}^{2} + 1\right) \cdot \left(y \cdot x\right)}\\

\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.8
Herbie5.2
\[\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 (/.f64 (/.f64 1 x) (*.f64 y (+.f64 1 (*.f64 z z)))) < -9.88131e-323 or -0.0 < (/.f64 (/.f64 1 x) (*.f64 y (+.f64 1 (*.f64 z z))))

    1. Initial program 0.3

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

    if -9.88131e-323 < (/.f64 (/.f64 1 x) (*.f64 y (+.f64 1 (*.f64 z z)))) < -0.0

    1. Initial program 14.8

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

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

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

      [Start]11.5

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

      rational.json-simplify-43 [=>]11.7

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

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

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

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

Alternatives

Alternative 1
Error6.5
Cost704
\[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
Alternative 2
Error29.2
Cost320
\[\frac{1}{y \cdot x} \]
Alternative 3
Error29.1
Cost320
\[\frac{\frac{1}{x}}{y} \]

Error

Reproduce?

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