?

Average Accuracy: 82.4% → 99.8%
Time: 10.9s
Precision: binary64
Cost: 19976

?

\[\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \]
\[\begin{array}{l} \mathbf{if}\;x \leq -4.1 \cdot 10^{+46}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{elif}\;x \leq 15:\\ \;\;\;\;\frac{{\left(e^{x}\right)}^{\log \left(\frac{x}{x + y}\right)}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{e^{y}}\\ \end{array} \]
(FPCore (x y) :precision binary64 (/ (exp (* x (log (/ x (+ x y))))) x))
(FPCore (x y)
 :precision binary64
 (if (<= x -4.1e+46)
   (/ (exp (- y)) x)
   (if (<= x 15.0)
     (/ (pow (exp x) (log (/ x (+ x y)))) x)
     (/ (/ 1.0 x) (exp y)))))
double code(double x, double y) {
	return exp((x * log((x / (x + y))))) / x;
}
double code(double x, double y) {
	double tmp;
	if (x <= -4.1e+46) {
		tmp = exp(-y) / x;
	} else if (x <= 15.0) {
		tmp = pow(exp(x), log((x / (x + y)))) / x;
	} else {
		tmp = (1.0 / x) / exp(y);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = exp((x * log((x / (x + y))))) / x
end function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= (-4.1d+46)) then
        tmp = exp(-y) / x
    else if (x <= 15.0d0) then
        tmp = (exp(x) ** log((x / (x + y)))) / x
    else
        tmp = (1.0d0 / x) / exp(y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	return Math.exp((x * Math.log((x / (x + y))))) / x;
}
public static double code(double x, double y) {
	double tmp;
	if (x <= -4.1e+46) {
		tmp = Math.exp(-y) / x;
	} else if (x <= 15.0) {
		tmp = Math.pow(Math.exp(x), Math.log((x / (x + y)))) / x;
	} else {
		tmp = (1.0 / x) / Math.exp(y);
	}
	return tmp;
}
def code(x, y):
	return math.exp((x * math.log((x / (x + y))))) / x
def code(x, y):
	tmp = 0
	if x <= -4.1e+46:
		tmp = math.exp(-y) / x
	elif x <= 15.0:
		tmp = math.pow(math.exp(x), math.log((x / (x + y)))) / x
	else:
		tmp = (1.0 / x) / math.exp(y)
	return tmp
function code(x, y)
	return Float64(exp(Float64(x * log(Float64(x / Float64(x + y))))) / x)
end
function code(x, y)
	tmp = 0.0
	if (x <= -4.1e+46)
		tmp = Float64(exp(Float64(-y)) / x);
	elseif (x <= 15.0)
		tmp = Float64((exp(x) ^ log(Float64(x / Float64(x + y)))) / x);
	else
		tmp = Float64(Float64(1.0 / x) / exp(y));
	end
	return tmp
end
function tmp = code(x, y)
	tmp = exp((x * log((x / (x + y))))) / x;
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -4.1e+46)
		tmp = exp(-y) / x;
	elseif (x <= 15.0)
		tmp = (exp(x) ^ log((x / (x + y)))) / x;
	else
		tmp = (1.0 / x) / exp(y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := N[(N[Exp[N[(x * N[Log[N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision]
code[x_, y_] := If[LessEqual[x, -4.1e+46], N[(N[Exp[(-y)], $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 15.0], N[(N[Power[N[Exp[x], $MachinePrecision], N[Log[N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / N[Exp[y], $MachinePrecision]), $MachinePrecision]]]
\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x}
\begin{array}{l}
\mathbf{if}\;x \leq -4.1 \cdot 10^{+46}:\\
\;\;\;\;\frac{e^{-y}}{x}\\

\mathbf{elif}\;x \leq 15:\\
\;\;\;\;\frac{{\left(e^{x}\right)}^{\log \left(\frac{x}{x + y}\right)}}{x}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{e^{y}}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original82.4%
Target87.8%
Herbie99.8%
\[\begin{array}{l} \mathbf{if}\;y < -3.7311844206647956 \cdot 10^{+94}:\\ \;\;\;\;\frac{e^{\frac{-1}{y}}}{x}\\ \mathbf{elif}\;y < 2.817959242728288 \cdot 10^{+37}:\\ \;\;\;\;\frac{{\left(\frac{x}{y + x}\right)}^{x}}{x}\\ \mathbf{elif}\;y < 2.347387415166998 \cdot 10^{+178}:\\ \;\;\;\;\log \left(e^{\frac{{\left(\frac{x}{y + x}\right)}^{x}}{x}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{\frac{-1}{y}}}{x}\\ \end{array} \]

Derivation?

  1. Split input into 3 regimes
  2. if x < -4.1e46

    1. Initial program 80.1%

      \[\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \]
    2. Simplified80.1%

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

      [Start]80.1

      \[ \frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \]

      *-commutative [=>]80.1

      \[ \frac{e^{\color{blue}{\log \left(\frac{x}{x + y}\right) \cdot x}}}{x} \]

      exp-to-pow [=>]80.1

      \[ \frac{\color{blue}{{\left(\frac{x}{x + y}\right)}^{x}}}{x} \]
    3. Taylor expanded in x around inf 100.0%

      \[\leadsto \frac{\color{blue}{e^{-1 \cdot y}}}{x} \]
    4. Simplified100.0%

      \[\leadsto \frac{\color{blue}{e^{-y}}}{x} \]
      Proof

      [Start]100.0

      \[ \frac{e^{-1 \cdot y}}{x} \]

      mul-1-neg [=>]100.0

      \[ \frac{e^{\color{blue}{-y}}}{x} \]

    if -4.1e46 < x < 15

    1. Initial program 82.5%

      \[\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \]
    2. Simplified99.6%

      \[\leadsto \color{blue}{\frac{{\left(e^{x}\right)}^{\log \left(\frac{x}{x + y}\right)}}{x}} \]
      Proof

      [Start]82.5

      \[ \frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \]

      exp-prod [=>]99.6

      \[ \frac{\color{blue}{{\left(e^{x}\right)}^{\log \left(\frac{x}{x + y}\right)}}}{x} \]

    if 15 < x

    1. Initial program 83.9%

      \[\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \]
    2. Simplified83.9%

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

      [Start]83.9

      \[ \frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \]

      *-commutative [=>]83.9

      \[ \frac{e^{\color{blue}{\log \left(\frac{x}{x + y}\right) \cdot x}}}{x} \]

      exp-to-pow [=>]83.9

      \[ \frac{\color{blue}{{\left(\frac{x}{x + y}\right)}^{x}}}{x} \]
    3. Taylor expanded in x around inf 99.9%

      \[\leadsto \frac{\color{blue}{e^{-1 \cdot y}}}{x} \]
    4. Simplified99.9%

      \[\leadsto \frac{\color{blue}{e^{-y}}}{x} \]
      Proof

      [Start]99.9

      \[ \frac{e^{-1 \cdot y}}{x} \]

      mul-1-neg [=>]99.9

      \[ \frac{e^{\color{blue}{-y}}}{x} \]
    5. Applied egg-rr99.9%

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

      [Start]99.9

      \[ \frac{e^{-y}}{x} \]

      clear-num [=>]99.9

      \[ \color{blue}{\frac{1}{\frac{x}{e^{-y}}}} \]

      inv-pow [=>]99.9

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

      div-inv [=>]99.9

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

      add-sqr-sqrt [=>]32.3

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

      sqrt-unprod [=>]65.2

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

      sqr-neg [=>]65.2

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

      sqrt-unprod [<=]32.9

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

      add-sqr-sqrt [<=]63.9

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

      exp-neg [<=]63.9

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

      add-sqr-sqrt [=>]31.0

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

      sqrt-unprod [=>]98.6

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

      sqr-neg [=>]98.6

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

      sqrt-unprod [<=]67.6

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

      add-sqr-sqrt [<=]99.9

      \[ {\left(x \cdot e^{\color{blue}{y}}\right)}^{-1} \]
    6. Taylor expanded in x around 0 99.9%

      \[\leadsto \color{blue}{\frac{1}{e^{y} \cdot x}} \]
    7. Simplified99.9%

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

      [Start]99.9

      \[ \frac{1}{e^{y} \cdot x} \]

      associate-/l/ [<=]99.9

      \[ \color{blue}{\frac{\frac{1}{x}}{e^{y}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.1 \cdot 10^{+46}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{elif}\;x \leq 15:\\ \;\;\;\;\frac{{\left(e^{x}\right)}^{\log \left(\frac{x}{x + y}\right)}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{e^{y}}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy99.2%
Cost6984
\[\begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{+50}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{elif}\;x \leq 0.58:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{e^{y}}\\ \end{array} \]
Alternative 2
Accuracy99.3%
Cost6921
\[\begin{array}{l} \mathbf{if}\;x \leq -4.1 \cdot 10^{+46} \lor \neg \left(x \leq 0.6\right):\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x}\\ \end{array} \]
Alternative 3
Accuracy97.9%
Cost580
\[\begin{array}{l} \mathbf{if}\;y \leq 38:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \frac{1}{x}\right) + -1\\ \end{array} \]
Alternative 4
Accuracy84.4%
Cost452
\[\begin{array}{l} \mathbf{if}\;y \leq 4.5 \cdot 10^{+59}:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot y}\\ \end{array} \]
Alternative 5
Accuracy85.0%
Cost192
\[\frac{1}{x} \]

Error

Reproduce?

herbie shell --seed 2023151 
(FPCore (x y)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, F"
  :precision binary64

  :herbie-target
  (if (< y -3.7311844206647956e+94) (/ (exp (/ -1.0 y)) x) (if (< y 2.817959242728288e+37) (/ (pow (/ x (+ y x)) x) x) (if (< y 2.347387415166998e+178) (log (exp (/ (pow (/ x (+ y x)) x) x))) (/ (exp (/ -1.0 y)) x))))

  (/ (exp (* x (log (/ x (+ x y))))) x))