Average Error: 6.1 → 0.1
Time: 4.4s
Precision: 64
\[x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -1116111820951900757028957439299745235337000 \lor \neg \left(y \le 1.292740669483186222166182233195286244154\right):\\ \;\;\;\;x + \frac{1 \cdot e^{-1 \cdot z}}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{{\left(e^{y}\right)}^{\left(\log \left(\frac{y}{z + y}\right)\right)}}{y}\\ \end{array}\]
x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}
\begin{array}{l}
\mathbf{if}\;y \le -1116111820951900757028957439299745235337000 \lor \neg \left(y \le 1.292740669483186222166182233195286244154\right):\\
\;\;\;\;x + \frac{1 \cdot e^{-1 \cdot z}}{y}\\

\mathbf{else}:\\
\;\;\;\;x + \frac{{\left(e^{y}\right)}^{\left(\log \left(\frac{y}{z + y}\right)\right)}}{y}\\

\end{array}
double f(double x, double y, double z) {
        double r422815 = x;
        double r422816 = y;
        double r422817 = z;
        double r422818 = r422817 + r422816;
        double r422819 = r422816 / r422818;
        double r422820 = log(r422819);
        double r422821 = r422816 * r422820;
        double r422822 = exp(r422821);
        double r422823 = r422822 / r422816;
        double r422824 = r422815 + r422823;
        return r422824;
}

double f(double x, double y, double z) {
        double r422825 = y;
        double r422826 = -1.1161118209519008e+42;
        bool r422827 = r422825 <= r422826;
        double r422828 = 1.2927406694831862;
        bool r422829 = r422825 <= r422828;
        double r422830 = !r422829;
        bool r422831 = r422827 || r422830;
        double r422832 = x;
        double r422833 = 1.0;
        double r422834 = -1.0;
        double r422835 = z;
        double r422836 = r422834 * r422835;
        double r422837 = exp(r422836);
        double r422838 = r422833 * r422837;
        double r422839 = r422838 / r422825;
        double r422840 = r422832 + r422839;
        double r422841 = exp(r422825);
        double r422842 = r422835 + r422825;
        double r422843 = r422825 / r422842;
        double r422844 = log(r422843);
        double r422845 = pow(r422841, r422844);
        double r422846 = r422845 / r422825;
        double r422847 = r422832 + r422846;
        double r422848 = r422831 ? r422840 : r422847;
        return r422848;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.1
Target1.3
Herbie0.1
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z + y} \lt 7.115415759790762719541517221498726780517 \cdot 10^{-315}:\\ \;\;\;\;x + \frac{e^{\frac{-1}{z}}}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{e^{\log \left({\left(\frac{y}{y + z}\right)}^{y}\right)}}{y}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -1.1161118209519008e+42 or 1.2927406694831862 < y

    1. Initial program 2.4

      \[x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity2.4

      \[\leadsto x + \frac{e^{y \cdot \log \left(\frac{y}{\color{blue}{1 \cdot \left(z + y\right)}}\right)}}{y}\]
    4. Applied *-un-lft-identity2.4

      \[\leadsto x + \frac{e^{y \cdot \log \left(\frac{\color{blue}{1 \cdot y}}{1 \cdot \left(z + y\right)}\right)}}{y}\]
    5. Applied times-frac2.4

      \[\leadsto x + \frac{e^{y \cdot \log \color{blue}{\left(\frac{1}{1} \cdot \frac{y}{z + y}\right)}}}{y}\]
    6. Applied log-prod2.4

      \[\leadsto x + \frac{e^{y \cdot \color{blue}{\left(\log \left(\frac{1}{1}\right) + \log \left(\frac{y}{z + y}\right)\right)}}}{y}\]
    7. Applied distribute-lft-in2.4

      \[\leadsto x + \frac{e^{\color{blue}{y \cdot \log \left(\frac{1}{1}\right) + y \cdot \log \left(\frac{y}{z + y}\right)}}}{y}\]
    8. Applied exp-sum2.4

      \[\leadsto x + \frac{\color{blue}{e^{y \cdot \log \left(\frac{1}{1}\right)} \cdot e^{y \cdot \log \left(\frac{y}{z + y}\right)}}}{y}\]
    9. Simplified2.4

      \[\leadsto x + \frac{\color{blue}{1} \cdot e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}\]
    10. Simplified2.4

      \[\leadsto x + \frac{1 \cdot \color{blue}{{\left(\frac{y}{z + y}\right)}^{y}}}{y}\]
    11. Taylor expanded around inf 0.0

      \[\leadsto x + \frac{1 \cdot \color{blue}{e^{-z}}}{y}\]
    12. Simplified0.0

      \[\leadsto x + \frac{1 \cdot \color{blue}{e^{-1 \cdot z}}}{y}\]

    if -1.1161118209519008e+42 < y < 1.2927406694831862

    1. Initial program 9.8

      \[x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}\]
    2. Using strategy rm
    3. Applied add-log-exp14.1

      \[\leadsto x + \frac{e^{\color{blue}{\log \left(e^{y}\right)} \cdot \log \left(\frac{y}{z + y}\right)}}{y}\]
    4. Applied exp-to-pow0.1

      \[\leadsto x + \frac{\color{blue}{{\left(e^{y}\right)}^{\left(\log \left(\frac{y}{z + y}\right)\right)}}}{y}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -1116111820951900757028957439299745235337000 \lor \neg \left(y \le 1.292740669483186222166182233195286244154\right):\\ \;\;\;\;x + \frac{1 \cdot e^{-1 \cdot z}}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{{\left(e^{y}\right)}^{\left(\log \left(\frac{y}{z + y}\right)\right)}}{y}\\ \end{array}\]

Reproduce

herbie shell --seed 2020001 +o rules:numerics
(FPCore (x y z)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, G"
  :precision binary64

  :herbie-target
  (if (< (/ y (+ z y)) 7.1154157597908e-315) (+ x (/ (exp (/ -1 z)) y)) (+ x (/ (exp (log (pow (/ y (+ y z)) y))) y)))

  (+ x (/ (exp (* y (log (/ y (+ z y))))) y)))