Average Error: 2.1 → 1.5
Time: 5.9m
Precision: 64
\[\frac{x \cdot e^{\left(y \cdot \log z + \left(t - 1\right) \cdot \log a\right) - b}}{y}\]
\[\frac{x \cdot \frac{{a}^{\left(-1\right)}}{e^{\mathsf{log1p}\left(\mathsf{expm1}\left(b - \mathsf{fma}\left(\log z, y, t \cdot \log a\right)\right)\right)}}}{y}\]
\frac{x \cdot e^{\left(y \cdot \log z + \left(t - 1\right) \cdot \log a\right) - b}}{y}
\frac{x \cdot \frac{{a}^{\left(-1\right)}}{e^{\mathsf{log1p}\left(\mathsf{expm1}\left(b - \mathsf{fma}\left(\log z, y, t \cdot \log a\right)\right)\right)}}}{y}
double f(double x, double y, double z, double t, double a, double b) {
        double r952394 = x;
        double r952395 = y;
        double r952396 = z;
        double r952397 = log(r952396);
        double r952398 = r952395 * r952397;
        double r952399 = t;
        double r952400 = 1.0;
        double r952401 = r952399 - r952400;
        double r952402 = a;
        double r952403 = log(r952402);
        double r952404 = r952401 * r952403;
        double r952405 = r952398 + r952404;
        double r952406 = b;
        double r952407 = r952405 - r952406;
        double r952408 = exp(r952407);
        double r952409 = r952394 * r952408;
        double r952410 = r952409 / r952395;
        return r952410;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r952411 = x;
        double r952412 = a;
        double r952413 = 1.0;
        double r952414 = -r952413;
        double r952415 = pow(r952412, r952414);
        double r952416 = b;
        double r952417 = z;
        double r952418 = log(r952417);
        double r952419 = y;
        double r952420 = t;
        double r952421 = log(r952412);
        double r952422 = r952420 * r952421;
        double r952423 = fma(r952418, r952419, r952422);
        double r952424 = r952416 - r952423;
        double r952425 = expm1(r952424);
        double r952426 = log1p(r952425);
        double r952427 = exp(r952426);
        double r952428 = r952415 / r952427;
        double r952429 = r952411 * r952428;
        double r952430 = r952429 / r952419;
        return r952430;
}

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.6
Herbie1.5
\[\begin{array}{l} \mathbf{if}\;t \lt -0.8845848504127471478852839936735108494759:\\ \;\;\;\;\frac{x \cdot \frac{{a}^{\left(t - 1\right)}}{y}}{\left(b + 1\right) - y \cdot \log z}\\ \mathbf{elif}\;t \lt 852031.228837407310493290424346923828125:\\ \;\;\;\;\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. Initial program 2.1

    \[\frac{x \cdot e^{\left(y \cdot \log z + \left(t - 1\right) \cdot \log a\right) - b}}{y}\]
  2. Taylor expanded around inf 2.1

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

    \[\leadsto \frac{x \cdot \color{blue}{\frac{{a}^{\left(-1\right)}}{e^{\mathsf{fma}\left(y, -\log z, \mathsf{fma}\left(t, -\log a, b\right)\right)}}}}{y}\]
  4. Using strategy rm
  5. Applied log1p-expm1-u1.5

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

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

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

Reproduce

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

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

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