?

Average Accuracy: 90.0% → 97.3%
Time: 11.7s
Precision: binary64
Cost: 1220

?

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original90.0%
Target92.2%
Herbie97.3%
\[\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 y (+.f64 1 (*.f64 z z))) < 3.9999999999999998e304

    1. Initial program 97.1%

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

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

      [Start]97.1

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

      distribute-rgt-in [=>]97.1

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

      *-un-lft-identity [<=]97.1

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

      flip-+ [=>]58.7

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

      associate-/r/ [=>]52.1

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

      inv-pow [=>]52.1

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

      associate-*l* [=>]52.1

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

      associate-*l* [=>]52.1

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

      associate-*l* [=>]54.3

      \[ \frac{{x}^{-1}}{y \cdot y - \left(z \cdot \left(z \cdot y\right)\right) \cdot \left(z \cdot \left(z \cdot y\right)\right)} \cdot \left(y - \color{blue}{z \cdot \left(z \cdot y\right)}\right) \]
    3. Simplified48.8%

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

      [Start]54.3

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

      associate-*l/ [=>]54.8

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

      unpow-1 [=>]54.8

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

      associate-*l/ [=>]54.9

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

      sub-neg [=>]54.9

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

      distribute-lft-in [=>]54.9

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

      *-lft-identity [=>]54.9

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

      *-commutative [<=]54.9

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

      cancel-sign-sub-inv [<=]54.9

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

      *-rgt-identity [=>]54.9

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

      associate-*r* [=>]54.1

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

      unpow2 [<=]54.1

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

      associate-*r* [=>]52.7

      \[ \frac{\frac{y - z \cdot \left(z \cdot y\right)}{x}}{y \cdot y - \color{blue}{\left(\left(z \cdot \left(z \cdot y\right)\right) \cdot {z}^{2}\right) \cdot y}} \]
    4. Applied egg-rr41.9%

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

      [Start]48.8

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

      expm1-log1p-u [=>]39.3

      \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{y - z \cdot \left(z \cdot y\right)}{x}}{y \cdot y - \left(y \cdot {z}^{4}\right) \cdot y}\right)\right)} \]

      expm1-udef [=>]23.5

      \[ \color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{y - z \cdot \left(z \cdot y\right)}{x}}{y \cdot y - \left(y \cdot {z}^{4}\right) \cdot y}\right)} - 1} \]
    5. Simplified98.5%

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

      [Start]41.9

      \[ e^{\mathsf{log1p}\left(\frac{1}{\left(y + z \cdot \left(y \cdot z\right)\right) \cdot x}\right)} - 1 \]

      expm1-def [=>]79.1

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

      expm1-log1p [=>]98.5

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

      *-commutative [=>]98.5

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

      *-commutative [=>]98.5

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

    if 3.9999999999999998e304 < (*.f64 y (+.f64 1 (*.f64 z z)))

    1. Initial program 71.5%

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

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

      [Start]71.5

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

      associate-/r* [=>]79.1

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

      \[\leadsto \color{blue}{\frac{1}{y \cdot \left({z}^{2} \cdot x\right)}} \]
    4. Simplified91.6%

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

      [Start]77.9

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

      associate-/r* [=>]78.1

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

      unpow2 [=>]78.1

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

      associate-*l* [=>]91.6

      \[ \frac{\frac{1}{y}}{\color{blue}{z \cdot \left(z \cdot x\right)}} \]
    5. Applied egg-rr94.0%

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

      [Start]91.6

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

      *-un-lft-identity [=>]91.6

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

      *-commutative [=>]91.6

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

      times-frac [=>]94.7

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

      associate-/l/ [=>]94.0

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

      *-commutative [=>]94.0

      \[ \frac{1}{z \cdot x} \cdot \frac{1}{\color{blue}{y \cdot z}} \]
    6. Applied egg-rr94.0%

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

      [Start]94.0

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

      un-div-inv [=>]94.0

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

      *-commutative [=>]94.0

      \[ \frac{\frac{1}{z \cdot x}}{\color{blue}{z \cdot y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.3%

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

Alternatives

Alternative 1
Accuracy97.0%
Cost13504
\[\frac{1}{\mathsf{hypot}\left(1, z\right) \cdot \left(\left(\mathsf{hypot}\left(1, z\right) \cdot y\right) \cdot x\right)} \]
Alternative 2
Accuracy93.5%
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\ \;\;\;\;\frac{1}{z \cdot \left(z \cdot \left(y \cdot x\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y}}{x}\\ \end{array} \]
Alternative 3
Accuracy96.3%
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -0.85 \lor \neg \left(z \leq 0.86\right):\\ \;\;\;\;\frac{\frac{1}{y \cdot \left(z \cdot x\right)}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - z \cdot z}{y \cdot x}\\ \end{array} \]
Alternative 4
Accuracy96.5%
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -0.88 \lor \neg \left(z \leq 0.86\right):\\ \;\;\;\;\frac{\frac{1}{z \cdot x}}{z \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - z \cdot z}{y \cdot x}\\ \end{array} \]
Alternative 5
Accuracy93.4%
Cost836
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 0.001:\\ \;\;\;\;\frac{1 - z \cdot z}{y \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z \cdot \left(z \cdot \left(y \cdot x\right)\right)}\\ \end{array} \]
Alternative 6
Accuracy54.5%
Cost320
\[\frac{1}{y \cdot x} \]

Error

Reproduce?

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