Average Error: 6.2 → 1.0
Time: 9.2s
Precision: 64
\[x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}\]
\[\begin{array}{l} \mathbf{if}\;y \le 1.4594586256060078 \cdot 10^{-19}:\\ \;\;\;\;x + \frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(e^{-z}, \frac{1}{y}, x\right)\\ \end{array}\]
x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}
\begin{array}{l}
\mathbf{if}\;y \le 1.4594586256060078 \cdot 10^{-19}:\\
\;\;\;\;x + \frac{1}{y}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(e^{-z}, \frac{1}{y}, x\right)\\

\end{array}
double f(double x, double y, double z) {
        double r6700125 = x;
        double r6700126 = y;
        double r6700127 = z;
        double r6700128 = r6700127 + r6700126;
        double r6700129 = r6700126 / r6700128;
        double r6700130 = log(r6700129);
        double r6700131 = r6700126 * r6700130;
        double r6700132 = exp(r6700131);
        double r6700133 = r6700132 / r6700126;
        double r6700134 = r6700125 + r6700133;
        return r6700134;
}

double f(double x, double y, double z) {
        double r6700135 = y;
        double r6700136 = 1.4594586256060078e-19;
        bool r6700137 = r6700135 <= r6700136;
        double r6700138 = x;
        double r6700139 = 1.0;
        double r6700140 = r6700139 / r6700135;
        double r6700141 = r6700138 + r6700140;
        double r6700142 = z;
        double r6700143 = -r6700142;
        double r6700144 = exp(r6700143);
        double r6700145 = fma(r6700144, r6700140, r6700138);
        double r6700146 = r6700137 ? r6700141 : r6700145;
        return r6700146;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.2
Target1.3
Herbie1.0
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z + y} \lt 7.1154157597908 \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.4594586256060078e-19

    1. Initial program 8.1

      \[x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}\]
    2. Taylor expanded around inf 1.2

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

    if 1.4594586256060078e-19 < y

    1. Initial program 2.0

      \[x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}\]
    2. Taylor expanded around inf 0.6

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

      \[\leadsto \color{blue}{\frac{e^{-z}}{y} + x}\]
    4. Using strategy rm
    5. Applied div-inv0.6

      \[\leadsto \color{blue}{e^{-z} \cdot \frac{1}{y}} + x\]
    6. Applied fma-def0.6

      \[\leadsto \color{blue}{\mathsf{fma}\left(e^{-z}, \frac{1}{y}, x\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le 1.4594586256060078 \cdot 10^{-19}:\\ \;\;\;\;x + \frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(e^{-z}, \frac{1}{y}, x\right)\\ \end{array}\]

Reproduce

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

  :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)))