Average Error: 10.6 → 2.2
Time: 4.2s
Precision: binary64
\[\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x}\]
\[\begin{array}{l} \mathbf{if}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq -2.072636373236087 \cdot 10^{+60}:\\ \;\;\;\;\frac{{\left(\frac{1}{\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}}\right)}^{x} \cdot {\left(\frac{x}{\sqrt[3]{x + y}}\right)}^{x}}{x}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq -2.422262997602561 \cdot 10^{-308}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq 0:\\ \;\;\;\;\frac{{\left(\frac{\sqrt{x}}{\sqrt{x + y}}\right)}^{x} \cdot {\left(\frac{\sqrt{x}}{\sqrt{x + y}}\right)}^{x}}{x}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq 1.3075445047601994 \cdot 10^{-13}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\sqrt{x} \cdot \frac{\sqrt{x}}{x + y}\right)}^{x}}{x}\\ \end{array}\]
\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x}
\begin{array}{l}
\mathbf{if}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq -2.072636373236087 \cdot 10^{+60}:\\
\;\;\;\;\frac{{\left(\frac{1}{\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}}\right)}^{x} \cdot {\left(\frac{x}{\sqrt[3]{x + y}}\right)}^{x}}{x}\\

\mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq -2.422262997602561 \cdot 10^{-308}:\\
\;\;\;\;\frac{e^{-y}}{x}\\

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

\mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq 1.3075445047601994 \cdot 10^{-13}:\\
\;\;\;\;\frac{e^{-y}}{x}\\

\mathbf{else}:\\
\;\;\;\;\frac{{\left(\sqrt{x} \cdot \frac{\sqrt{x}}{x + y}\right)}^{x}}{x}\\

\end{array}
(FPCore (x y) :precision binary64 (/ (exp (* x (log (/ x (+ x y))))) x))
(FPCore (x y)
 :precision binary64
 (if (<= (/ (exp (* x (log (/ x (+ x y))))) x) -2.072636373236087e+60)
   (/
    (*
     (pow (/ 1.0 (* (cbrt (+ x y)) (cbrt (+ x y)))) x)
     (pow (/ x (cbrt (+ x y))) x))
    x)
   (if (<= (/ (exp (* x (log (/ x (+ x y))))) x) -2.422262997602561e-308)
     (/ (exp (- y)) x)
     (if (<= (/ (exp (* x (log (/ x (+ x y))))) x) 0.0)
       (/
        (*
         (pow (/ (sqrt x) (sqrt (+ x y))) x)
         (pow (/ (sqrt x) (sqrt (+ x y))) x))
        x)
       (if (<= (/ (exp (* x (log (/ x (+ x y))))) x) 1.3075445047601994e-13)
         (/ (exp (- y)) x)
         (/ (pow (* (sqrt x) (/ (sqrt x) (+ x y))) x) x))))))
double code(double x, double y) {
	return exp(x * log(x / (x + y))) / x;
}
double code(double x, double y) {
	double tmp;
	if ((exp(x * log(x / (x + y))) / x) <= -2.072636373236087e+60) {
		tmp = (pow((1.0 / (cbrt(x + y) * cbrt(x + y))), x) * pow((x / cbrt(x + y)), x)) / x;
	} else if ((exp(x * log(x / (x + y))) / x) <= -2.422262997602561e-308) {
		tmp = exp(-y) / x;
	} else if ((exp(x * log(x / (x + y))) / x) <= 0.0) {
		tmp = (pow((sqrt(x) / sqrt(x + y)), x) * pow((sqrt(x) / sqrt(x + y)), x)) / x;
	} else if ((exp(x * log(x / (x + y))) / x) <= 1.3075445047601994e-13) {
		tmp = exp(-y) / x;
	} else {
		tmp = pow((sqrt(x) * (sqrt(x) / (x + y))), x) / x;
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10.6
Target7.9
Herbie2.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) < -2.0726363732360869e60

    1. Initial program 15.1

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

      \[\leadsto \color{blue}{\frac{{\left(\frac{x}{x + y}\right)}^{x}}{x}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt_binary64_1136615.1

      \[\leadsto \frac{{\left(\frac{x}{\color{blue}{\left(\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}\right) \cdot \sqrt[3]{x + y}}}\right)}^{x}}{x}\]
    5. Applied *-un-lft-identity_binary64_1133115.1

      \[\leadsto \frac{{\left(\frac{\color{blue}{1 \cdot x}}{\left(\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}\right) \cdot \sqrt[3]{x + y}}\right)}^{x}}{x}\]
    6. Applied times-frac_binary64_1133715.1

      \[\leadsto \frac{{\color{blue}{\left(\frac{1}{\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}} \cdot \frac{x}{\sqrt[3]{x + y}}\right)}}^{x}}{x}\]
    7. Applied unpow-prod-down_binary64_114103.2

      \[\leadsto \frac{\color{blue}{{\left(\frac{1}{\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}}\right)}^{x} \cdot {\left(\frac{x}{\sqrt[3]{x + y}}\right)}^{x}}}{x}\]

    if -2.0726363732360869e60 < (/.f64 (exp.f64 (*.f64 x (log.f64 (/.f64 x (+.f64 x y))))) x) < -2.42226299760256108e-308 or 0.0 < (/.f64 (exp.f64 (*.f64 x (log.f64 (/.f64 x (+.f64 x y))))) x) < 1.3075445047601994e-13

    1. Initial program 10.6

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

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

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

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

    1. Initial program 24.7

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

      \[\leadsto \color{blue}{\frac{{\left(\frac{x}{x + y}\right)}^{x}}{x}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt_binary64_1135328.2

      \[\leadsto \frac{{\left(\frac{x}{\color{blue}{\sqrt{x + y} \cdot \sqrt{x + y}}}\right)}^{x}}{x}\]
    5. Applied add-sqr-sqrt_binary64_1135328.3

      \[\leadsto \frac{{\left(\frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{\sqrt{x + y} \cdot \sqrt{x + y}}\right)}^{x}}{x}\]
    6. Applied times-frac_binary64_1133728.3

      \[\leadsto \frac{{\color{blue}{\left(\frac{\sqrt{x}}{\sqrt{x + y}} \cdot \frac{\sqrt{x}}{\sqrt{x + y}}\right)}}^{x}}{x}\]
    7. Applied unpow-prod-down_binary64_114103.7

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

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

    1. Initial program 0.0

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

      \[\leadsto \color{blue}{\frac{{\left(\frac{x}{x + y}\right)}^{x}}{x}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity_binary64_113310.0

      \[\leadsto \frac{{\left(\frac{x}{\color{blue}{1 \cdot \left(x + y\right)}}\right)}^{x}}{x}\]
    5. Applied add-sqr-sqrt_binary64_113530.4

      \[\leadsto \frac{{\left(\frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{1 \cdot \left(x + y\right)}\right)}^{x}}{x}\]
    6. Applied times-frac_binary64_113370.4

      \[\leadsto \frac{{\color{blue}{\left(\frac{\sqrt{x}}{1} \cdot \frac{\sqrt{x}}{x + y}\right)}}^{x}}{x}\]
    7. Simplified0.4

      \[\leadsto \frac{{\left(\color{blue}{\sqrt{x}} \cdot \frac{\sqrt{x}}{x + y}\right)}^{x}}{x}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification2.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq -2.072636373236087 \cdot 10^{+60}:\\ \;\;\;\;\frac{{\left(\frac{1}{\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}}\right)}^{x} \cdot {\left(\frac{x}{\sqrt[3]{x + y}}\right)}^{x}}{x}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq -2.422262997602561 \cdot 10^{-308}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq 0:\\ \;\;\;\;\frac{{\left(\frac{\sqrt{x}}{\sqrt{x + y}}\right)}^{x} \cdot {\left(\frac{\sqrt{x}}{\sqrt{x + y}}\right)}^{x}}{x}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq 1.3075445047601994 \cdot 10^{-13}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\sqrt{x} \cdot \frac{\sqrt{x}}{x + y}\right)}^{x}}{x}\\ \end{array}\]

Reproduce

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