Average Error: 26.3 → 0.8
Time: 14.7s
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 -5.01836415789685645 \cdot 10^{54} \lor \neg \left(x \le 6.95058600294961662 \cdot 10^{46}\right):\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}}\right) - 110.11392429848109\\ \mathbf{else}:\\ \;\;\;\;\frac{\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)}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}} \cdot \frac{{x}^{3} - {2}^{3}}{\mathsf{fma}\left(x, x, 2 \cdot \left(x + 2\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\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 -5.01836415789685645 \cdot 10^{54} \lor \neg \left(x \le 6.95058600294961662 \cdot 10^{46}\right):\\
\;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}}\right) - 110.11392429848109\\

\mathbf{else}:\\
\;\;\;\;\frac{\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)}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}} \cdot \frac{{x}^{3} - {2}^{3}}{\mathsf{fma}\left(x, x, 2 \cdot \left(x + 2\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}\\

\end{array}
double f(double x, double y, double z) {
        double r506462 = x;
        double r506463 = 2.0;
        double r506464 = r506462 - r506463;
        double r506465 = 4.16438922228;
        double r506466 = r506462 * r506465;
        double r506467 = 78.6994924154;
        double r506468 = r506466 + r506467;
        double r506469 = r506468 * r506462;
        double r506470 = 137.519416416;
        double r506471 = r506469 + r506470;
        double r506472 = r506471 * r506462;
        double r506473 = y;
        double r506474 = r506472 + r506473;
        double r506475 = r506474 * r506462;
        double r506476 = z;
        double r506477 = r506475 + r506476;
        double r506478 = r506464 * r506477;
        double r506479 = 43.3400022514;
        double r506480 = r506462 + r506479;
        double r506481 = r506480 * r506462;
        double r506482 = 263.505074721;
        double r506483 = r506481 + r506482;
        double r506484 = r506483 * r506462;
        double r506485 = 313.399215894;
        double r506486 = r506484 + r506485;
        double r506487 = r506486 * r506462;
        double r506488 = 47.066876606;
        double r506489 = r506487 + r506488;
        double r506490 = r506478 / r506489;
        return r506490;
}

double f(double x, double y, double z) {
        double r506491 = x;
        double r506492 = -5.0183641578968565e+54;
        bool r506493 = r506491 <= r506492;
        double r506494 = 6.950586002949617e+46;
        bool r506495 = r506491 <= r506494;
        double r506496 = !r506495;
        bool r506497 = r506493 || r506496;
        double r506498 = 4.16438922228;
        double r506499 = y;
        double r506500 = 2.0;
        double r506501 = pow(r506491, r506500);
        double r506502 = r506499 / r506501;
        double r506503 = fma(r506491, r506498, r506502);
        double r506504 = 110.1139242984811;
        double r506505 = r506503 - r506504;
        double r506506 = 78.6994924154;
        double r506507 = fma(r506491, r506498, r506506);
        double r506508 = 137.519416416;
        double r506509 = fma(r506507, r506491, r506508);
        double r506510 = fma(r506509, r506491, r506499);
        double r506511 = z;
        double r506512 = fma(r506510, r506491, r506511);
        double r506513 = 43.3400022514;
        double r506514 = r506491 + r506513;
        double r506515 = 263.505074721;
        double r506516 = fma(r506514, r506491, r506515);
        double r506517 = 313.399215894;
        double r506518 = fma(r506516, r506491, r506517);
        double r506519 = 47.066876606;
        double r506520 = fma(r506518, r506491, r506519);
        double r506521 = sqrt(r506520);
        double r506522 = r506512 / r506521;
        double r506523 = 3.0;
        double r506524 = pow(r506491, r506523);
        double r506525 = 2.0;
        double r506526 = pow(r506525, r506523);
        double r506527 = r506524 - r506526;
        double r506528 = r506491 + r506525;
        double r506529 = r506525 * r506528;
        double r506530 = fma(r506491, r506491, r506529);
        double r506531 = r506530 * r506521;
        double r506532 = r506527 / r506531;
        double r506533 = r506522 * r506532;
        double r506534 = r506497 ? r506505 : r506533;
        return r506534;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original26.3
Target0.4
Herbie0.8
\[\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 < -5.0183641578968565e+54 or 6.950586002949617e+46 < x

    1. Initial program 61.8

      \[\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.8

      \[\leadsto \color{blue}{\frac{\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)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}\]
    3. Taylor expanded around inf 0.6

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

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

    if -5.0183641578968565e+54 < x < 6.950586002949617e+46

    1. Initial program 1.1

      \[\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. Simplified1.1

      \[\leadsto \color{blue}{\frac{\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)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt1.2

      \[\leadsto \frac{\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)}{\color{blue}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)} \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}}\]
    5. Applied times-frac0.9

      \[\leadsto \color{blue}{\frac{\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)}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}} \cdot \frac{x - 2}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}}\]
    6. Using strategy rm
    7. Applied flip3--0.9

      \[\leadsto \frac{\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)}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}} \cdot \frac{\color{blue}{\frac{{x}^{3} - {2}^{3}}{x \cdot x + \left(2 \cdot 2 + x \cdot 2\right)}}}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}\]
    8. Applied associate-/l/0.9

      \[\leadsto \frac{\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)}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}} \cdot \color{blue}{\frac{{x}^{3} - {2}^{3}}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)} \cdot \left(x \cdot x + \left(2 \cdot 2 + x \cdot 2\right)\right)}}\]
    9. Simplified0.9

      \[\leadsto \frac{\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)}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}} \cdot \frac{{x}^{3} - {2}^{3}}{\color{blue}{\mathsf{fma}\left(x, x, 2 \cdot \left(x + 2\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -5.01836415789685645 \cdot 10^{54} \lor \neg \left(x \le 6.95058600294961662 \cdot 10^{46}\right):\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}}\right) - 110.11392429848109\\ \mathbf{else}:\\ \;\;\;\;\frac{\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)}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}} \cdot \frac{{x}^{3} - {2}^{3}}{\mathsf{fma}\left(x, x, 2 \cdot \left(x + 2\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020042 +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)))