Average Error: 11.0 → 3.2
Time: 8.4s
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 -33729989078041.62:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq -1.7207415369154863 \cdot 10^{-265}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq 0:\\ \;\;\;\;\frac{e^{x \cdot \left(\log x - \log \left(x + y\right)\right)}}{x}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq 1.5382303982872333 \cdot 10^{-46}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}}\right)}^{x} \cdot {\left(\frac{\sqrt[3]{x}}{\sqrt[3]{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 -33729989078041.62:\\
\;\;\;\;\frac{1}{x}\\

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{{\left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}}\right)}^{x} \cdot {\left(\frac{\sqrt[3]{x}}{\sqrt[3]{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) -33729989078041.62)
   (/ 1.0 x)
   (if (<= (/ (exp (* x (log (/ x (+ x y))))) x) -1.7207415369154863e-265)
     (/ (exp (- y)) x)
     (if (<= (/ (exp (* x (log (/ x (+ x y))))) x) 0.0)
       (/ (exp (* x (- (log x) (log (+ x y))))) x)
       (if (<= (/ (exp (* x (log (/ x (+ x y))))) x) 1.5382303982872333e-46)
         (/ (exp (- y)) x)
         (/
          (*
           (pow (/ (* (cbrt x) (cbrt x)) (* (cbrt (+ x y)) (cbrt (+ x y)))) x)
           (pow (/ (cbrt x) (cbrt (+ 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) <= -33729989078041.62) {
		tmp = 1.0 / x;
	} else if ((exp(x * log(x / (x + y))) / x) <= -1.7207415369154863e-265) {
		tmp = exp(-y) / x;
	} else if ((exp(x * log(x / (x + y))) / x) <= 0.0) {
		tmp = exp(x * (log(x) - log(x + y))) / x;
	} else if ((exp(x * log(x / (x + y))) / x) <= 1.5382303982872333e-46) {
		tmp = exp(-y) / x;
	} else {
		tmp = (pow(((cbrt(x) * cbrt(x)) / (cbrt(x + y) * cbrt(x + y))), x) * pow((cbrt(x) / cbrt(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

Original11.0
Target7.9
Herbie3.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) < -33729989078041.6211

    1. Initial program 12.2

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

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

      \[\leadsto \frac{\color{blue}{1}}{x}\]

    if -33729989078041.6211 < (/.f64 (exp.f64 (*.f64 x (log.f64 (/.f64 x (+.f64 x y))))) x) < -1.7207415369154863e-265 or 0.0 < (/.f64 (exp.f64 (*.f64 x (log.f64 (/.f64 x (+.f64 x y))))) x) < 1.5382303982872333e-46

    1. Initial program 12.0

      \[\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}}\]
    3. Taylor expanded around inf 0.5

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

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

    1. Initial program 23.9

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

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

      \[\leadsto \frac{{\left(\frac{x}{\color{blue}{e^{\log \left(x + y\right)}}}\right)}^{x}}{x}\]
    5. Applied add-exp-log_binary6439.7

      \[\leadsto \frac{{\left(\frac{\color{blue}{e^{\log x}}}{e^{\log \left(x + y\right)}}\right)}^{x}}{x}\]
    6. Applied div-exp_binary6439.7

      \[\leadsto \frac{{\color{blue}{\left(e^{\log x - \log \left(x + y\right)}\right)}}^{x}}{x}\]
    7. Applied pow-exp_binary6420.9

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

    if 1.5382303982872333e-46 < (/.f64 (exp.f64 (*.f64 x (log.f64 (/.f64 x (+.f64 x y))))) x)

    1. Initial program 0.4

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

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

      \[\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 add-cube-cbrt_binary640.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq -33729989078041.62:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq -1.7207415369154863 \cdot 10^{-265}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq 0:\\ \;\;\;\;\frac{e^{x \cdot \left(\log x - \log \left(x + y\right)\right)}}{x}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq 1.5382303982872333 \cdot 10^{-46}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}}\right)}^{x} \cdot {\left(\frac{\sqrt[3]{x}}{\sqrt[3]{x + y}}\right)}^{x}}{x}\\ \end{array}\]

Alternatives

Reproduce

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