?

Average Error: 11.3 → 0.8
Time: 9.9s
Precision: binary64
Cost: 6921

?

\[\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \]
\[\begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+21} \lor \neg \left(x \leq 1.3 \cdot 10^{-31}\right):\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x}\\ \end{array} \]
(FPCore (x y) :precision binary64 (/ (exp (* x (log (/ x (+ x y))))) x))
(FPCore (x y)
 :precision binary64
 (if (or (<= x -1e+21) (not (<= x 1.3e-31))) (/ (exp (- y)) x) (/ 1.0 x)))
double code(double x, double y) {
	return exp((x * log((x / (x + y))))) / x;
}
double code(double x, double y) {
	double tmp;
	if ((x <= -1e+21) || !(x <= 1.3e-31)) {
		tmp = exp(-y) / x;
	} else {
		tmp = 1.0 / 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) :: tmp
    if ((x <= (-1d+21)) .or. (.not. (x <= 1.3d-31))) then
        tmp = exp(-y) / x
    else
        tmp = 1.0d0 / 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 tmp;
	if ((x <= -1e+21) || !(x <= 1.3e-31)) {
		tmp = Math.exp(-y) / x;
	} else {
		tmp = 1.0 / x;
	}
	return tmp;
}
def code(x, y):
	return math.exp((x * math.log((x / (x + y))))) / x
def code(x, y):
	tmp = 0
	if (x <= -1e+21) or not (x <= 1.3e-31):
		tmp = math.exp(-y) / x
	else:
		tmp = 1.0 / x
	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 <= -1e+21) || !(x <= 1.3e-31))
		tmp = Float64(exp(Float64(-y)) / x);
	else
		tmp = Float64(1.0 / 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)
	tmp = 0.0;
	if ((x <= -1e+21) || ~((x <= 1.3e-31)))
		tmp = exp(-y) / x;
	else
		tmp = 1.0 / 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_] := If[Or[LessEqual[x, -1e+21], N[Not[LessEqual[x, 1.3e-31]], $MachinePrecision]], N[(N[Exp[(-y)], $MachinePrecision] / x), $MachinePrecision], N[(1.0 / x), $MachinePrecision]]
\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x}
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+21} \lor \neg \left(x \leq 1.3 \cdot 10^{-31}\right):\\
\;\;\;\;\frac{e^{-y}}{x}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{x}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original11.3
Target8.0
Herbie0.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 2 regimes
  2. if x < -1e21 or 1.29999999999999998e-31 < x

    1. Initial program 10.8

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

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

      [Start]10.8

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

      *-commutative [=>]10.8

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

      exp-to-pow [=>]10.8

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

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

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

      [Start]1.2

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

      mul-1-neg [=>]1.2

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

    if -1e21 < x < 1.29999999999999998e-31

    1. Initial program 11.9

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

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

      [Start]11.9

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

      *-commutative [=>]11.9

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

      exp-to-pow [=>]11.9

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

      \[\leadsto \frac{\color{blue}{1}}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+21} \lor \neg \left(x \leq 1.3 \cdot 10^{-31}\right):\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x}\\ \end{array} \]

Alternatives

Alternative 1
Error3.5
Cost33544
\[\begin{array}{l} t_0 := \log \left(\frac{x}{x + y}\right)\\ t_1 := \frac{e^{x \cdot t_0}}{x}\\ \mathbf{if}\;t_1 \leq 0:\\ \;\;\;\;\frac{{\left(e^{x}\right)}^{t_0}}{x}\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{-94}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x}\\ \end{array} \]
Alternative 2
Error6.6
Cost1617
\[\begin{array}{l} \mathbf{if}\;x \leq 4.6 \cdot 10^{+17}:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{+97}:\\ \;\;\;\;\frac{x \cdot x}{\left(x \cdot x\right) \cdot \left(x + x \cdot y\right)}\\ \mathbf{elif}\;x \leq 8.8 \cdot 10^{+134} \lor \neg \left(x \leq 1.55 \cdot 10^{+225}\right):\\ \;\;\;\;\frac{1}{x \cdot \left(y + 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - y \cdot y}{\frac{x \cdot \left(y \cdot y + -1\right)}{y + -1}}\\ \end{array} \]
Alternative 3
Error7.2
Cost580
\[\begin{array}{l} \mathbf{if}\;x \leq 1.3 \cdot 10^{-31}:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot \left(y + 1\right)}\\ \end{array} \]
Alternative 4
Error9.8
Cost192
\[\frac{1}{x} \]

Error

Reproduce?

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