Average Error: 11.5 → 1.6
Time: 7.9s
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 -8.132958944010024 \cdot 10^{+27}:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq -3.578189530103608 \cdot 10^{-204}:\\ \;\;\;\;\frac{1}{x \cdot e^{y}}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq 0:\\ \;\;\;\;\frac{{\left(e^{x}\right)}^{\left(\frac{-y}{x}\right)}}{x}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq 1.820444830454397 \cdot 10^{-66}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(e^{\sqrt{x}}\right)}^{\left(\log \left(\frac{x}{x + y}\right) \cdot \sqrt{x}\right)}}{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 -8.132958944010024 \cdot 10^{+27}:\\
\;\;\;\;\frac{1}{x}\\

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{{\left(e^{\sqrt{x}}\right)}^{\left(\log \left(\frac{x}{x + y}\right) \cdot \sqrt{x}\right)}}{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) -8.132958944010024e+27)
   (/ 1.0 x)
   (if (<= (/ (exp (* x (log (/ x (+ x y))))) x) -3.578189530103608e-204)
     (/ 1.0 (* x (exp y)))
     (if (<= (/ (exp (* x (log (/ x (+ x y))))) x) 0.0)
       (/ (pow (exp x) (/ (- y) x)) x)
       (if (<= (/ (exp (* x (log (/ x (+ x y))))) x) 1.820444830454397e-66)
         (/ (exp (- y)) x)
         (/ (pow (exp (sqrt x)) (* (log (/ x (+ x y))) (sqrt 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) <= -8.132958944010024e+27) {
		tmp = 1.0 / x;
	} else if ((exp(x * log(x / (x + y))) / x) <= -3.578189530103608e-204) {
		tmp = 1.0 / (x * exp(y));
	} else if ((exp(x * log(x / (x + y))) / x) <= 0.0) {
		tmp = pow(exp(x), (-y / x)) / x;
	} else if ((exp(x * log(x / (x + y))) / x) <= 1.820444830454397e-66) {
		tmp = exp(-y) / x;
	} else {
		tmp = pow(exp(sqrt(x)), (log(x / (x + y)) * sqrt(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.5
Target7.9
Herbie1.6
\[\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 5 regimes
  2. if (/.f64 (exp.f64 (*.f64 x (log.f64 (/.f64 x (+.f64 x y))))) x) < -8.1329589440100238e27

    1. Initial program 13.1

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

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

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

      \[\leadsto \frac{{\left(e^{x}\right)}^{\color{blue}{\left(-\frac{y}{x}\right)}}}{x}\]
    5. Taylor expanded around inf 0.1

      \[\leadsto \frac{\color{blue}{e^{-1 \cdot \frac{y \cdot \log \left(e^{x}\right)}{x}}}}{x}\]
    6. Simplified25.8

      \[\leadsto \frac{\color{blue}{e^{-y}}}{x}\]
    7. Taylor expanded around 0 0.1

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

    if -8.1329589440100238e27 < (/.f64 (exp.f64 (*.f64 x (log.f64 (/.f64 x (+.f64 x y))))) x) < -3.57818953010360778e-204

    1. Initial program 7.7

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

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

      \[\leadsto \frac{{\left(e^{x}\right)}^{\color{blue}{\left(-1 \cdot \frac{y}{x}\right)}}}{x}\]
    4. Simplified33.8

      \[\leadsto \frac{{\left(e^{x}\right)}^{\color{blue}{\left(-\frac{y}{x}\right)}}}{x}\]
    5. Taylor expanded around inf 47.4

      \[\leadsto \frac{\color{blue}{e^{-1 \cdot \frac{y \cdot \log \left(e^{x}\right)}{x}}}}{x}\]
    6. Simplified2.8

      \[\leadsto \frac{\color{blue}{e^{-y}}}{x}\]
    7. Using strategy rm
    8. Applied neg-sub0_binary64_184872.8

      \[\leadsto \frac{e^{\color{blue}{0 - y}}}{x}\]
    9. Applied exp-diff_binary64_185402.8

      \[\leadsto \frac{\color{blue}{\frac{e^{0}}{e^{y}}}}{x}\]
    10. Applied associate-/l/_binary64_184392.8

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

    if -3.57818953010360778e-204 < (/.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. Simplified8.8

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

      \[\leadsto \frac{{\left(e^{x}\right)}^{\color{blue}{\left(-1 \cdot \frac{y}{x}\right)}}}{x}\]
    4. Simplified4.8

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

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

    1. Initial program 14.0

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

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

      \[\leadsto \frac{{\left(e^{x}\right)}^{\color{blue}{\left(-1 \cdot \frac{y}{x}\right)}}}{x}\]
    4. Simplified22.6

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

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

    if 1.820444830454397e-66 < (/.f64 (exp.f64 (*.f64 x (log.f64 (/.f64 x (+.f64 x y))))) x)

    1. Initial program 0.5

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

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

      \[\leadsto \frac{{\left(e^{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right)}^{\log \left(\frac{x}{x + y}\right)}}{x}\]
    5. Applied exp-prod_binary64_185440.8

      \[\leadsto \frac{{\color{blue}{\left({\left(e^{\sqrt{x}}\right)}^{\left(\sqrt{x}\right)}\right)}}^{\log \left(\frac{x}{x + y}\right)}}{x}\]
    6. Applied pow-pow_binary64_185640.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq -8.132958944010024 \cdot 10^{+27}:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq -3.578189530103608 \cdot 10^{-204}:\\ \;\;\;\;\frac{1}{x \cdot e^{y}}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq 0:\\ \;\;\;\;\frac{{\left(e^{x}\right)}^{\left(\frac{-y}{x}\right)}}{x}\\ \mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq 1.820444830454397 \cdot 10^{-66}:\\ \;\;\;\;\frac{e^{-y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(e^{\sqrt{x}}\right)}^{\left(\log \left(\frac{x}{x + y}\right) \cdot \sqrt{x}\right)}}{x}\\ \end{array}\]

Reproduce

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