?

Average Accuracy: 78.6% → 99.2%
Time: 11.6s
Precision: binary64
Cost: 60688

?

\[\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \]
\[\begin{array}{l} t_0 := \frac{x}{x + y}\\ t_1 := \log t_0\\ t_2 := \frac{e^{x \cdot t_1}}{x}\\ t_3 := \frac{{\left(e^{x}\right)}^{t_1}}{x}\\ \mathbf{if}\;t_2 \leq -50000000000000:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq -4 \cdot 10^{-304}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{-13}:\\ \;\;\;\;\frac{\frac{1}{x}}{e^{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{{t_0}^{x}}{x}\\ \end{array} \]
(FPCore (x y) :precision binary64 (/ (exp (* x (log (/ x (+ x y))))) x))
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (+ x y)))
        (t_1 (log t_0))
        (t_2 (/ (exp (* x t_1)) x))
        (t_3 (/ (pow (exp x) t_1) x)))
   (if (<= t_2 -50000000000000.0)
     t_3
     (if (<= t_2 -4e-304)
       (/ (exp (- y)) x)
       (if (<= t_2 0.0)
         t_3
         (if (<= t_2 5e-13) (/ (/ 1.0 x) (exp y)) (/ (pow t_0 x) x)))))))
double code(double x, double y) {
	return exp((x * log((x / (x + y))))) / x;
}
double code(double x, double y) {
	double t_0 = x / (x + y);
	double t_1 = log(t_0);
	double t_2 = exp((x * t_1)) / x;
	double t_3 = pow(exp(x), t_1) / x;
	double tmp;
	if (t_2 <= -50000000000000.0) {
		tmp = t_3;
	} else if (t_2 <= -4e-304) {
		tmp = exp(-y) / x;
	} else if (t_2 <= 0.0) {
		tmp = t_3;
	} else if (t_2 <= 5e-13) {
		tmp = (1.0 / x) / exp(y);
	} else {
		tmp = pow(t_0, x) / x;
	}
	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) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_0 = x / (x + y)
    t_1 = log(t_0)
    t_2 = exp((x * t_1)) / x
    t_3 = (exp(x) ** t_1) / x
    if (t_2 <= (-50000000000000.0d0)) then
        tmp = t_3
    else if (t_2 <= (-4d-304)) then
        tmp = exp(-y) / x
    else if (t_2 <= 0.0d0) then
        tmp = t_3
    else if (t_2 <= 5d-13) then
        tmp = (1.0d0 / x) / exp(y)
    else
        tmp = (t_0 ** x) / x
    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 t_0 = x / (x + y);
	double t_1 = Math.log(t_0);
	double t_2 = Math.exp((x * t_1)) / x;
	double t_3 = Math.pow(Math.exp(x), t_1) / x;
	double tmp;
	if (t_2 <= -50000000000000.0) {
		tmp = t_3;
	} else if (t_2 <= -4e-304) {
		tmp = Math.exp(-y) / x;
	} else if (t_2 <= 0.0) {
		tmp = t_3;
	} else if (t_2 <= 5e-13) {
		tmp = (1.0 / x) / Math.exp(y);
	} else {
		tmp = Math.pow(t_0, x) / x;
	}
	return tmp;
}
def code(x, y):
	return math.exp((x * math.log((x / (x + y))))) / x
def code(x, y):
	t_0 = x / (x + y)
	t_1 = math.log(t_0)
	t_2 = math.exp((x * t_1)) / x
	t_3 = math.pow(math.exp(x), t_1) / x
	tmp = 0
	if t_2 <= -50000000000000.0:
		tmp = t_3
	elif t_2 <= -4e-304:
		tmp = math.exp(-y) / x
	elif t_2 <= 0.0:
		tmp = t_3
	elif t_2 <= 5e-13:
		tmp = (1.0 / x) / math.exp(y)
	else:
		tmp = math.pow(t_0, x) / x
	return tmp
function code(x, y)
	return Float64(exp(Float64(x * log(Float64(x / Float64(x + y))))) / x)
end
function code(x, y)
	t_0 = Float64(x / Float64(x + y))
	t_1 = log(t_0)
	t_2 = Float64(exp(Float64(x * t_1)) / x)
	t_3 = Float64((exp(x) ^ t_1) / x)
	tmp = 0.0
	if (t_2 <= -50000000000000.0)
		tmp = t_3;
	elseif (t_2 <= -4e-304)
		tmp = Float64(exp(Float64(-y)) / x);
	elseif (t_2 <= 0.0)
		tmp = t_3;
	elseif (t_2 <= 5e-13)
		tmp = Float64(Float64(1.0 / x) / exp(y));
	else
		tmp = Float64((t_0 ^ x) / x);
	end
	return tmp
end
function tmp = code(x, y)
	tmp = exp((x * log((x / (x + y))))) / x;
end
function tmp_2 = code(x, y)
	t_0 = x / (x + y);
	t_1 = log(t_0);
	t_2 = exp((x * t_1)) / x;
	t_3 = (exp(x) ^ t_1) / x;
	tmp = 0.0;
	if (t_2 <= -50000000000000.0)
		tmp = t_3;
	elseif (t_2 <= -4e-304)
		tmp = exp(-y) / x;
	elseif (t_2 <= 0.0)
		tmp = t_3;
	elseif (t_2 <= 5e-13)
		tmp = (1.0 / x) / exp(y);
	else
		tmp = (t_0 ^ x) / x;
	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_] := Block[{t$95$0 = N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Log[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Exp[N[(x * t$95$1), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[N[Exp[x], $MachinePrecision], t$95$1], $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$2, -50000000000000.0], t$95$3, If[LessEqual[t$95$2, -4e-304], N[(N[Exp[(-y)], $MachinePrecision] / x), $MachinePrecision], If[LessEqual[t$95$2, 0.0], t$95$3, If[LessEqual[t$95$2, 5e-13], N[(N[(1.0 / x), $MachinePrecision] / N[Exp[y], $MachinePrecision]), $MachinePrecision], N[(N[Power[t$95$0, x], $MachinePrecision] / x), $MachinePrecision]]]]]]]]]
\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x}
\begin{array}{l}
t_0 := \frac{x}{x + y}\\
t_1 := \log t_0\\
t_2 := \frac{e^{x \cdot t_1}}{x}\\
t_3 := \frac{{\left(e^{x}\right)}^{t_1}}{x}\\
\mathbf{if}\;t_2 \leq -50000000000000:\\
\;\;\;\;t_3\\

\mathbf{elif}\;t_2 \leq -4 \cdot 10^{-304}:\\
\;\;\;\;\frac{e^{-y}}{x}\\

\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;t_3\\

\mathbf{elif}\;t_2 \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{\frac{1}{x}}{e^{y}}\\

\mathbf{else}:\\
\;\;\;\;\frac{{t_0}^{x}}{x}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original78.6%
Target77.6%
Herbie99.2%
\[\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 4 regimes
  2. if (/.f64 (exp.f64 (*.f64 x (log.f64 (/.f64 x (+.f64 x y))))) x) < -5e13 or -3.99999999999999988e-304 < (/.f64 (exp.f64 (*.f64 x (log.f64 (/.f64 x (+.f64 x y))))) x) < 0.0

    1. Initial program 78.7%

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

      \[\leadsto \color{blue}{\frac{{\left(e^{x}\right)}^{\log \left(\frac{x}{x + y}\right)}}{x}} \]
      Step-by-step derivation

      [Start]78.7

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

      exp-prod [=>]99.9

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

    if -5e13 < (/.f64 (exp.f64 (*.f64 x (log.f64 (/.f64 x (+.f64 x y))))) x) < -3.99999999999999988e-304

    1. Initial program 66.0%

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

      \[\leadsto \color{blue}{\frac{{\left(\frac{x}{x + y}\right)}^{x}}{x}} \]
      Step-by-step derivation

      [Start]66.0

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

      *-commutative [=>]66.0

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

      exp-to-pow [=>]66.0

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

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

      \[\leadsto \frac{\color{blue}{e^{-y}}}{x} \]
      Step-by-step derivation

      [Start]98.4

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

      mul-1-neg [=>]98.4

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

    if 0.0 < (/.f64 (exp.f64 (*.f64 x (log.f64 (/.f64 x (+.f64 x y))))) x) < 4.9999999999999999e-13

    1. Initial program 60.4%

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

      \[\leadsto \color{blue}{\frac{{\left(\frac{x}{x + y}\right)}^{x}}{x}} \]
      Step-by-step derivation

      [Start]60.4

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

      *-commutative [=>]60.4

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

      exp-to-pow [=>]60.4

      \[ \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} \]
      Step-by-step derivation

      [Start]99.9

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

      mul-1-neg [=>]99.9

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

      \[\leadsto \color{blue}{{\left(x \cdot e^{y}\right)}^{-1}} \]
      Step-by-step derivation

      [Start]99.9

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

      clear-num [=>]100.0

      \[ \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 [=>]52.5

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

      sqrt-unprod [=>]84.2

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

      sqr-neg [=>]84.2

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

      sqrt-unprod [<=]31.7

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

      add-sqr-sqrt [<=]59.3

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

      exp-neg [<=]59.3

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

      add-sqr-sqrt [=>]27.6

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

      sqrt-unprod [=>]75.1

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

      sqr-neg [=>]75.1

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

      sqrt-unprod [<=]47.4

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

      add-sqr-sqrt [<=]100.0

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{x}}{e^{y}}} \]
      Step-by-step derivation

      [Start]100.0

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

      associate-/l/ [<=]100.0

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

    if 4.9999999999999999e-13 < (/.f64 (exp.f64 (*.f64 x (log.f64 (/.f64 x (+.f64 x y))))) x)

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\frac{{\left(\frac{x}{x + y}\right)}^{x}}{x}} \]
      Step-by-step derivation

      [Start]100.0

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

      *-commutative [=>]100.0

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

      exp-to-pow [=>]100.0

      \[ \frac{\color{blue}{{\left(\frac{x}{x + y}\right)}^{x}}}{x} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification99.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq -50000000000000:\\ \;\;\;\;\frac{{\left(e^{x}\right)}^{\log \left(\frac{x}{x + y}\right)}}{x}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq -4 \cdot 10^{-304}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq 0:\\ \;\;\;\;\frac{{\left(e^{x}\right)}^{\log \left(\frac{x}{x + y}\right)}}{x}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq 5 \cdot 10^{-13}:\\ \;\;\;\;\frac{\frac{1}{x}}{e^{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\frac{x}{x + y}\right)}^{x}}{x}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy99.3%
Cost6984
\[\begin{array}{l} \mathbf{if}\;x \leq -0.12:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{elif}\;x \leq 0.000175:\\ \;\;\;\;\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 -0.54 \lor \neg \left(x \leq 0.0001\right):\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x}\\ \end{array} \]
Alternative 3
Accuracy86.9%
Cost964
\[\begin{array}{l} \mathbf{if}\;y \leq -1.5 \cdot 10^{+173}:\\ \;\;\;\;\frac{\frac{1}{x} \cdot \left(1 - y \cdot y\right)}{y + 1}\\ \mathbf{elif}\;y \leq 47:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \frac{1}{x}\right) + -1\\ \end{array} \]
Alternative 4
Accuracy77.5%
Cost852
\[\begin{array}{l} \mathbf{if}\;y \leq 340:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{+76}:\\ \;\;\;\;0\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{+122}:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{elif}\;y \leq 1.12 \cdot 10^{+224}:\\ \;\;\;\;0\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{+294}:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
Alternative 5
Accuracy85.4%
Cost580
\[\begin{array}{l} \mathbf{if}\;y \leq 63:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \frac{1}{x}\right) + -1\\ \end{array} \]
Alternative 6
Accuracy15.3%
Cost64
\[0 \]

Error

Reproduce?

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