?

Average Error: 10.01% → 0.99%
Time: 11.2s
Precision: binary64
Cost: 1736

?

\[ \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(1 + z \cdot z\right)\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;\frac{\frac{\frac{\frac{1}{y}}{z}}{z}}{x}\\ \mathbf{elif}\;t_0 \leq 10^{+307}:\\ \;\;\;\;\frac{\frac{-1}{y \cdot \left(-1 - z \cdot z\right)}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y \cdot \left(z \cdot x\right)}}{z}\\ \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 (+ 1.0 (* z z)))))
   (if (<= t_0 (- INFINITY))
     (/ (/ (/ (/ 1.0 y) z) z) x)
     (if (<= t_0 1e+307)
       (/ (/ -1.0 (* y (- -1.0 (* z z)))) x)
       (/ (/ 1.0 (* y (* z x))) 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 t_0 = y * (1.0 + (z * z));
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = (((1.0 / y) / z) / z) / x;
	} else if (t_0 <= 1e+307) {
		tmp = (-1.0 / (y * (-1.0 - (z * z)))) / x;
	} else {
		tmp = (1.0 / (y * (z * x))) / z;
	}
	return tmp;
}
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 * (1.0 + (z * z));
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = (((1.0 / y) / z) / z) / x;
	} else if (t_0 <= 1e+307) {
		tmp = (-1.0 / (y * (-1.0 - (z * z)))) / x;
	} else {
		tmp = (1.0 / (y * (z * x))) / z;
	}
	return tmp;
}
def code(x, y, z):
	return (1.0 / x) / (y * (1.0 + (z * z)))
def code(x, y, z):
	t_0 = y * (1.0 + (z * z))
	tmp = 0
	if t_0 <= -math.inf:
		tmp = (((1.0 / y) / z) / z) / x
	elif t_0 <= 1e+307:
		tmp = (-1.0 / (y * (-1.0 - (z * z)))) / x
	else:
		tmp = (1.0 / (y * (z * x))) / 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)
	t_0 = Float64(y * Float64(1.0 + Float64(z * z)))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(Float64(Float64(Float64(1.0 / y) / z) / z) / x);
	elseif (t_0 <= 1e+307)
		tmp = Float64(Float64(-1.0 / Float64(y * Float64(-1.0 - Float64(z * z)))) / x);
	else
		tmp = Float64(Float64(1.0 / Float64(y * Float64(z * x))) / 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)
	t_0 = y * (1.0 + (z * z));
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = (((1.0 / y) / z) / z) / x;
	elseif (t_0 <= 1e+307)
		tmp = (-1.0 / (y * (-1.0 - (z * z)))) / x;
	else
		tmp = (1.0 / (y * (z * x))) / 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_] := Block[{t$95$0 = N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(N[(N[(1.0 / y), $MachinePrecision] / z), $MachinePrecision] / z), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[t$95$0, 1e+307], N[(N[(-1.0 / N[(y * N[(-1.0 - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[(1.0 / N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]]
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\begin{array}{l}
t_0 := y \cdot \left(1 + z \cdot z\right)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\frac{\frac{\frac{\frac{1}{y}}{z}}{z}}{x}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y \cdot \left(z \cdot x\right)}}{z}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10.01%
Target7.83%
Herbie0.99%
\[\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 (*.f64 y (+.f64 1 (*.f64 z z))) < -inf.0

    1. Initial program 27.05

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

      \[\leadsto \color{blue}{\frac{-1}{x} \cdot \frac{1}{\mathsf{fma}\left(z, z, 1\right) \cdot \left(-y\right)}} \]
    3. Simplified27.05

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

      [Start]27.05

      \[ \frac{-1}{x} \cdot \frac{1}{\mathsf{fma}\left(z, z, 1\right) \cdot \left(-y\right)} \]

      associate-*l/ [=>]27.05

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

      associate-*r/ [=>]27.05

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

      metadata-eval [=>]27.05

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

      distribute-rgt-neg-out [=>]27.05

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

      *-commutative [<=]27.05

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

      distribute-rgt-neg-in [=>]27.05

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

      fma-udef [=>]27.05

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

      +-commutative [<=]27.05

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

      distribute-neg-in [=>]27.05

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

      metadata-eval [=>]27.05

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

      neg-sub0 [=>]27.05

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

      associate-+r- [=>]27.05

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

      metadata-eval [=>]27.05

      \[ \frac{\frac{-1}{y \cdot \left(\color{blue}{-1} - z \cdot z\right)}}{x} \]
    4. Taylor expanded in z around inf 27.05

      \[\leadsto \frac{\color{blue}{\frac{1}{y \cdot {z}^{2}}}}{x} \]
    5. Simplified2.4

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

      [Start]27.05

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

      associate-/r* [=>]27.05

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

      unpow2 [=>]27.05

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

      associate-/r* [=>]2.4

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

    if -inf.0 < (*.f64 y (+.f64 1 (*.f64 z z))) < 9.99999999999999986e306

    1. Initial program 0.43

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

      \[\leadsto \color{blue}{\frac{-1}{x} \cdot \frac{1}{\mathsf{fma}\left(z, z, 1\right) \cdot \left(-y\right)}} \]
    3. Simplified0.41

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

      [Start]0.54

      \[ \frac{-1}{x} \cdot \frac{1}{\mathsf{fma}\left(z, z, 1\right) \cdot \left(-y\right)} \]

      associate-*l/ [=>]0.42

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

      associate-*r/ [=>]0.42

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

      metadata-eval [=>]0.42

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

      distribute-rgt-neg-out [=>]0.42

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

      *-commutative [<=]0.42

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

      distribute-rgt-neg-in [=>]0.42

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

      fma-udef [=>]0.41

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

      +-commutative [<=]0.41

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

      distribute-neg-in [=>]0.41

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

      metadata-eval [=>]0.41

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

      neg-sub0 [=>]0.41

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

      associate-+r- [=>]0.41

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

      metadata-eval [=>]0.41

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

    if 9.99999999999999986e306 < (*.f64 y (+.f64 1 (*.f64 z z)))

    1. Initial program 28.67

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

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

      [Start]28.67

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

      associate-/r* [=>]20.94

      \[ \color{blue}{\frac{\frac{\frac{1}{x}}{y}}{1 + z \cdot z}} \]
    3. Taylor expanded in z around inf 21.37

      \[\leadsto \frac{\frac{\frac{1}{x}}{y}}{\color{blue}{{z}^{2}}} \]
    4. Simplified21.37

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

      [Start]21.37

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

      unpow2 [=>]21.37

      \[ \frac{\frac{\frac{1}{x}}{y}}{\color{blue}{z \cdot z}} \]
    5. Applied egg-rr5.5

      \[\leadsto \color{blue}{-\frac{\frac{\frac{1}{x}}{y \cdot z}}{-z}} \]
    6. Taylor expanded in x around 0 21.28

      \[\leadsto -\color{blue}{\frac{-1}{y \cdot \left({z}^{2} \cdot x\right)}} \]
    7. Simplified2.02

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

      [Start]21.28

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

      associate-*r* [=>]29.12

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

      unpow2 [=>]29.12

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

      +-rgt-identity [<=]29.12

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

      *-commutative [=>]29.12

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

      associate-*r* [<=]21.56

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

      +-rgt-identity [=>]21.56

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

      associate-*r* [<=]10.01

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

      *-commutative [=>]10.01

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

      associate-/r* [=>]9.13

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

      associate-*r* [=>]5.49

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

      *-commutative [<=]5.49

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

      associate-*r* [<=]2.02

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

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

Alternatives

Alternative 1
Error1.05%
Cost1220
\[\begin{array}{l} \mathbf{if}\;y \cdot \left(1 + z \cdot z\right) \leq 10^{+307}:\\ \;\;\;\;\frac{\frac{1}{x}}{y + z \cdot \left(y \cdot z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y \cdot \left(z \cdot x\right)}}{z}\\ \end{array} \]
Alternative 2
Error3.54%
Cost900
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 10^{-6}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{-1}{x}}{y \cdot z}}{-z}\\ \end{array} \]
Alternative 3
Error6.7%
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(y \cdot z\right)\right)}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y \cdot \left(z \cdot \left(z \cdot x\right)\right)}\\ \end{array} \]
Alternative 4
Error6.61%
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(y \cdot z\right)\right)}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y}}{z \cdot \left(z \cdot x\right)}\\ \end{array} \]
Alternative 5
Error6.33%
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;\frac{\frac{\frac{\frac{1}{y}}{z}}{z}}{x}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y}}{z \cdot \left(z \cdot x\right)}\\ \end{array} \]
Alternative 6
Error3.29%
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;\frac{\frac{1}{y \cdot \left(z \cdot x\right)}}{z}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{z \cdot x}}{y \cdot z}\\ \end{array} \]
Alternative 7
Error6.7%
Cost836
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 10^{-6}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(y \cdot z\right)\right)}\\ \end{array} \]
Alternative 8
Error3.45%
Cost836
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 10^{-6}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y \cdot \left(z \cdot x\right)}}{z}\\ \end{array} \]
Alternative 9
Error45.29%
Cost320
\[\frac{1}{y \cdot x} \]
Alternative 10
Error45.34%
Cost320
\[\frac{\frac{1}{x}}{y} \]
Alternative 11
Error45.34%
Cost320
\[\frac{\frac{1}{y}}{x} \]

Error

Reproduce?

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