Average Error: 2.1 → 4.0
Time: 16.8s
Precision: 64
\[\frac{x \cdot e^{\left(y \cdot \log z + \left(t - 1\right) \cdot \log a\right) - b}}{y}\]
\[\begin{array}{l} \mathbf{if}\;\left(t - 1\right) \cdot \log a \le -2.9642058948872463 \cdot 10^{33} \lor \neg \left(\left(t - 1\right) \cdot \log a \le 69.882973088183576\right):\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{{e}^{\left(\mathsf{fma}\left(y, \log z, \left(t - 1\right) \cdot \log a\right) - b\right)} \cdot x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{{a}^{\left(t - 1\right)} \cdot {z}^{y}} \cdot e^{b}}\\ \end{array}\]
\frac{x \cdot e^{\left(y \cdot \log z + \left(t - 1\right) \cdot \log a\right) - b}}{y}
\begin{array}{l}
\mathbf{if}\;\left(t - 1\right) \cdot \log a \le -2.9642058948872463 \cdot 10^{33} \lor \neg \left(\left(t - 1\right) \cdot \log a \le 69.882973088183576\right):\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{{e}^{\left(\mathsf{fma}\left(y, \log z, \left(t - 1\right) \cdot \log a\right) - b\right)} \cdot x}{y}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{y}{{a}^{\left(t - 1\right)} \cdot {z}^{y}} \cdot e^{b}}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r470357 = x;
        double r470358 = y;
        double r470359 = z;
        double r470360 = log(r470359);
        double r470361 = r470358 * r470360;
        double r470362 = t;
        double r470363 = 1.0;
        double r470364 = r470362 - r470363;
        double r470365 = a;
        double r470366 = log(r470365);
        double r470367 = r470364 * r470366;
        double r470368 = r470361 + r470367;
        double r470369 = b;
        double r470370 = r470368 - r470369;
        double r470371 = exp(r470370);
        double r470372 = r470357 * r470371;
        double r470373 = r470372 / r470358;
        return r470373;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r470374 = t;
        double r470375 = 1.0;
        double r470376 = r470374 - r470375;
        double r470377 = a;
        double r470378 = log(r470377);
        double r470379 = r470376 * r470378;
        double r470380 = -2.9642058948872463e+33;
        bool r470381 = r470379 <= r470380;
        double r470382 = 69.88297308818358;
        bool r470383 = r470379 <= r470382;
        double r470384 = !r470383;
        bool r470385 = r470381 || r470384;
        double r470386 = exp(1.0);
        double r470387 = y;
        double r470388 = z;
        double r470389 = log(r470388);
        double r470390 = fma(r470387, r470389, r470379);
        double r470391 = b;
        double r470392 = r470390 - r470391;
        double r470393 = pow(r470386, r470392);
        double r470394 = x;
        double r470395 = r470393 * r470394;
        double r470396 = r470395 / r470387;
        double r470397 = log1p(r470396);
        double r470398 = expm1(r470397);
        double r470399 = pow(r470377, r470376);
        double r470400 = pow(r470388, r470387);
        double r470401 = r470399 * r470400;
        double r470402 = r470387 / r470401;
        double r470403 = exp(r470391);
        double r470404 = r470402 * r470403;
        double r470405 = r470394 / r470404;
        double r470406 = r470385 ? r470398 : r470405;
        return r470406;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Bits error versus b

Target

Original2.1
Target11.3
Herbie4.0
\[\begin{array}{l} \mathbf{if}\;t \lt -0.88458485041274715:\\ \;\;\;\;\frac{x \cdot \frac{{a}^{\left(t - 1\right)}}{y}}{\left(b + 1\right) - y \cdot \log z}\\ \mathbf{elif}\;t \lt 852031.22883740731:\\ \;\;\;\;\frac{\frac{x}{y} \cdot {a}^{\left(t - 1\right)}}{e^{b - \log z \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \frac{{a}^{\left(t - 1\right)}}{y}}{\left(b + 1\right) - y \cdot \log z}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (* (- t 1.0) (log a)) < -2.9642058948872463e+33 or 69.88297308818358 < (* (- t 1.0) (log a))

    1. Initial program 0.5

      \[\frac{x \cdot e^{\left(y \cdot \log z + \left(t - 1\right) \cdot \log a\right) - b}}{y}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity0.5

      \[\leadsto \frac{x \cdot e^{\color{blue}{1 \cdot \left(\left(y \cdot \log z + \left(t - 1\right) \cdot \log a\right) - b\right)}}}{y}\]
    4. Applied exp-prod0.5

      \[\leadsto \frac{x \cdot \color{blue}{{\left(e^{1}\right)}^{\left(\left(y \cdot \log z + \left(t - 1\right) \cdot \log a\right) - b\right)}}}{y}\]
    5. Simplified0.5

      \[\leadsto \frac{x \cdot {\color{blue}{e}}^{\left(\left(y \cdot \log z + \left(t - 1\right) \cdot \log a\right) - b\right)}}{y}\]
    6. Using strategy rm
    7. Applied expm1-log1p-u2.5

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x \cdot {e}^{\left(\left(y \cdot \log z + \left(t - 1\right) \cdot \log a\right) - b\right)}}{y}\right)\right)}\]
    8. Simplified2.5

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\frac{{e}^{\left(\mathsf{fma}\left(y, \log z, \left(t - 1\right) \cdot \log a\right) - b\right)} \cdot x}{y}\right)}\right)\]

    if -2.9642058948872463e+33 < (* (- t 1.0) (log a)) < 69.88297308818358

    1. Initial program 5.1

      \[\frac{x \cdot e^{\left(y \cdot \log z + \left(t - 1\right) \cdot \log a\right) - b}}{y}\]
    2. Using strategy rm
    3. Applied associate-/l*1.9

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

      \[\leadsto \frac{x}{\color{blue}{\frac{y}{{a}^{\left(t - 1\right)} \cdot {z}^{y}} \cdot e^{b}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification4.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(t - 1\right) \cdot \log a \le -2.9642058948872463 \cdot 10^{33} \lor \neg \left(\left(t - 1\right) \cdot \log a \le 69.882973088183576\right):\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{{e}^{\left(\mathsf{fma}\left(y, \log z, \left(t - 1\right) \cdot \log a\right) - b\right)} \cdot x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{{a}^{\left(t - 1\right)} \cdot {z}^{y}} \cdot e^{b}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020045 +o rules:numerics
(FPCore (x y z t a b)
  :name "Numeric.SpecFunctions:incompleteBetaWorker from math-functions-0.1.5.2, A"
  :precision binary64

  :herbie-target
  (if (< t -0.8845848504127471) (/ (* x (/ (pow a (- t 1)) y)) (- (+ b 1) (* y (log z)))) (if (< t 852031.2288374073) (/ (* (/ x y) (pow a (- t 1))) (exp (- b (* (log z) y)))) (/ (* x (/ (pow a (- t 1)) y)) (- (+ b 1) (* y (log z))))))

  (/ (* x (exp (- (+ (* y (log z)) (* (- t 1) (log a))) b))) y))