Average Error: 27.0 → 0.6
Time: 7.9s
Precision: 64
\[\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999964 + 78.6994924154000017\right) \cdot x + 137.51941641600001\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000014\right) \cdot x + 263.50507472100003\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606000001}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.00748404459321153 \cdot 10^{53} \lor \neg \left(x \le 7.52701502731127716 \cdot 10^{73}\right):\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}} - 110.11392429848109\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot x - 2 \cdot 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right) \cdot x + 137.51941641600001, x, y\right), x, z\right)} \cdot \left(x + 2\right)}\\ \end{array}\]
\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999964 + 78.6994924154000017\right) \cdot x + 137.51941641600001\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000014\right) \cdot x + 263.50507472100003\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606000001}
\begin{array}{l}
\mathbf{if}\;x \le -1.00748404459321153 \cdot 10^{53} \lor \neg \left(x \le 7.52701502731127716 \cdot 10^{73}\right):\\
\;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}} - 110.11392429848109\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot x - 2 \cdot 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right) \cdot x + 137.51941641600001, x, y\right), x, z\right)} \cdot \left(x + 2\right)}\\

\end{array}
double f(double x, double y, double z) {
        double r287515 = x;
        double r287516 = 2.0;
        double r287517 = r287515 - r287516;
        double r287518 = 4.16438922228;
        double r287519 = r287515 * r287518;
        double r287520 = 78.6994924154;
        double r287521 = r287519 + r287520;
        double r287522 = r287521 * r287515;
        double r287523 = 137.519416416;
        double r287524 = r287522 + r287523;
        double r287525 = r287524 * r287515;
        double r287526 = y;
        double r287527 = r287525 + r287526;
        double r287528 = r287527 * r287515;
        double r287529 = z;
        double r287530 = r287528 + r287529;
        double r287531 = r287517 * r287530;
        double r287532 = 43.3400022514;
        double r287533 = r287515 + r287532;
        double r287534 = r287533 * r287515;
        double r287535 = 263.505074721;
        double r287536 = r287534 + r287535;
        double r287537 = r287536 * r287515;
        double r287538 = 313.399215894;
        double r287539 = r287537 + r287538;
        double r287540 = r287539 * r287515;
        double r287541 = 47.066876606;
        double r287542 = r287540 + r287541;
        double r287543 = r287531 / r287542;
        return r287543;
}

double f(double x, double y, double z) {
        double r287544 = x;
        double r287545 = -1.0074840445932115e+53;
        bool r287546 = r287544 <= r287545;
        double r287547 = 7.527015027311277e+73;
        bool r287548 = r287544 <= r287547;
        double r287549 = !r287548;
        bool r287550 = r287546 || r287549;
        double r287551 = 4.16438922228;
        double r287552 = y;
        double r287553 = 2.0;
        double r287554 = pow(r287544, r287553);
        double r287555 = r287552 / r287554;
        double r287556 = 110.1139242984811;
        double r287557 = r287555 - r287556;
        double r287558 = fma(r287544, r287551, r287557);
        double r287559 = r287544 * r287544;
        double r287560 = 2.0;
        double r287561 = r287560 * r287560;
        double r287562 = r287559 - r287561;
        double r287563 = 43.3400022514;
        double r287564 = r287544 + r287563;
        double r287565 = 263.505074721;
        double r287566 = fma(r287564, r287544, r287565);
        double r287567 = 313.399215894;
        double r287568 = fma(r287566, r287544, r287567);
        double r287569 = 47.066876606;
        double r287570 = fma(r287568, r287544, r287569);
        double r287571 = 78.6994924154;
        double r287572 = fma(r287544, r287551, r287571);
        double r287573 = r287572 * r287544;
        double r287574 = 137.519416416;
        double r287575 = r287573 + r287574;
        double r287576 = fma(r287575, r287544, r287552);
        double r287577 = z;
        double r287578 = fma(r287576, r287544, r287577);
        double r287579 = r287570 / r287578;
        double r287580 = r287544 + r287560;
        double r287581 = r287579 * r287580;
        double r287582 = r287562 / r287581;
        double r287583 = r287550 ? r287558 : r287582;
        return r287583;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original27.0
Target0.5
Herbie0.6
\[\begin{array}{l} \mathbf{if}\;x \lt -3.3261287258700048 \cdot 10^{62}:\\ \;\;\;\;\left(\frac{y}{x \cdot x} + 4.16438922227999964 \cdot x\right) - 110.11392429848109\\ \mathbf{elif}\;x \lt 9.4299917145546727 \cdot 10^{55}:\\ \;\;\;\;\frac{x - 2}{1} \cdot \frac{\left(\left(\left(x \cdot 4.16438922227999964 + 78.6994924154000017\right) \cdot x + 137.51941641600001\right) \cdot x + y\right) \cdot x + z}{\left(\left(263.50507472100003 \cdot x + \left(43.3400022514000014 \cdot \left(x \cdot x\right) + x \cdot \left(x \cdot x\right)\right)\right) + 313.399215894\right) \cdot x + 47.066876606000001}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{y}{x \cdot x} + 4.16438922227999964 \cdot x\right) - 110.11392429848109\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -1.0074840445932115e+53 or 7.527015027311277e+73 < x

    1. Initial program 63.2

      \[\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999964 + 78.6994924154000017\right) \cdot x + 137.51941641600001\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000014\right) \cdot x + 263.50507472100003\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606000001}\]
    2. Simplified61.2

      \[\leadsto \color{blue}{\frac{x - 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)}}}\]
    3. Taylor expanded around inf 0.2

      \[\leadsto \color{blue}{\left(\frac{y}{{x}^{2}} + 4.16438922227999964 \cdot x\right) - 110.11392429848109}\]
    4. Simplified0.2

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}} - 110.11392429848109\right)}\]

    if -1.0074840445932115e+53 < x < 7.527015027311277e+73

    1. Initial program 2.6

      \[\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999964 + 78.6994924154000017\right) \cdot x + 137.51941641600001\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000014\right) \cdot x + 263.50507472100003\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606000001}\]
    2. Simplified0.9

      \[\leadsto \color{blue}{\frac{x - 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)}}}\]
    3. Using strategy rm
    4. Applied flip--0.9

      \[\leadsto \frac{\color{blue}{\frac{x \cdot x - 2 \cdot 2}{x + 2}}}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)}}\]
    5. Applied associate-/l/0.9

      \[\leadsto \color{blue}{\frac{x \cdot x - 2 \cdot 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)} \cdot \left(x + 2\right)}}\]
    6. Using strategy rm
    7. Applied fma-udef0.9

      \[\leadsto \frac{x \cdot x - 2 \cdot 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right) \cdot x + 137.51941641600001}, x, y\right), x, z\right)} \cdot \left(x + 2\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.00748404459321153 \cdot 10^{53} \lor \neg \left(x \le 7.52701502731127716 \cdot 10^{73}\right):\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}} - 110.11392429848109\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot x - 2 \cdot 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right) \cdot x + 137.51941641600001, x, y\right), x, z\right)} \cdot \left(x + 2\right)}\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< x -3.326128725870005e+62) (- (+ (/ y (* x x)) (* 4.16438922228 x)) 110.1139242984811) (if (< x 9.429991714554673e+55) (* (/ (- x 2) 1) (/ (+ (* (+ (* (+ (* (+ (* x 4.16438922228) 78.6994924154) x) 137.519416416) x) y) x) z) (+ (* (+ (+ (* 263.505074721 x) (+ (* 43.3400022514 (* x x)) (* x (* x x)))) 313.399215894) x) 47.066876606))) (- (+ (/ y (* x x)) (* 4.16438922228 x)) 110.1139242984811)))

  (/ (* (- x 2) (+ (* (+ (* (+ (* (+ (* x 4.16438922228) 78.6994924154) x) 137.519416416) x) y) x) z)) (+ (* (+ (* (+ (* (+ x 43.3400022514) x) 263.505074721) x) 313.399215894) x) 47.066876606)))