Average Error: 26.0 → 0.8
Time: 34.7s
Precision: 64
\[\frac{\left(x - 2.0\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606}\]
\[\begin{array}{l} \mathbf{if}\;x \le -5.140336158145698 \cdot 10^{+17}:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922228, \frac{\frac{y}{x}}{x}\right) - 110.1139242984811\\ \mathbf{elif}\;x \le 1.692613215272597 \cdot 10^{+44}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(4.16438922228, x, 78.6994924154\right), x, 137.519416416\right), y\right), x, z\right)}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}{{x}^{3} - \left(2.0 \cdot 2.0\right) \cdot 2.0}}}{\left(2.0 \cdot x + 2.0 \cdot 2.0\right) + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922228, \frac{\frac{y}{x}}{x}\right) - 110.1139242984811\\ \end{array}\]
\frac{\left(x - 2.0\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606}
\begin{array}{l}
\mathbf{if}\;x \le -5.140336158145698 \cdot 10^{+17}:\\
\;\;\;\;\mathsf{fma}\left(x, 4.16438922228, \frac{\frac{y}{x}}{x}\right) - 110.1139242984811\\

\mathbf{elif}\;x \le 1.692613215272597 \cdot 10^{+44}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(4.16438922228, x, 78.6994924154\right), x, 137.519416416\right), y\right), x, z\right)}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}{{x}^{3} - \left(2.0 \cdot 2.0\right) \cdot 2.0}}}{\left(2.0 \cdot x + 2.0 \cdot 2.0\right) + x \cdot x}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, 4.16438922228, \frac{\frac{y}{x}}{x}\right) - 110.1139242984811\\

\end{array}
double f(double x, double y, double z) {
        double r19277621 = x;
        double r19277622 = 2.0;
        double r19277623 = r19277621 - r19277622;
        double r19277624 = 4.16438922228;
        double r19277625 = r19277621 * r19277624;
        double r19277626 = 78.6994924154;
        double r19277627 = r19277625 + r19277626;
        double r19277628 = r19277627 * r19277621;
        double r19277629 = 137.519416416;
        double r19277630 = r19277628 + r19277629;
        double r19277631 = r19277630 * r19277621;
        double r19277632 = y;
        double r19277633 = r19277631 + r19277632;
        double r19277634 = r19277633 * r19277621;
        double r19277635 = z;
        double r19277636 = r19277634 + r19277635;
        double r19277637 = r19277623 * r19277636;
        double r19277638 = 43.3400022514;
        double r19277639 = r19277621 + r19277638;
        double r19277640 = r19277639 * r19277621;
        double r19277641 = 263.505074721;
        double r19277642 = r19277640 + r19277641;
        double r19277643 = r19277642 * r19277621;
        double r19277644 = 313.399215894;
        double r19277645 = r19277643 + r19277644;
        double r19277646 = r19277645 * r19277621;
        double r19277647 = 47.066876606;
        double r19277648 = r19277646 + r19277647;
        double r19277649 = r19277637 / r19277648;
        return r19277649;
}

double f(double x, double y, double z) {
        double r19277650 = x;
        double r19277651 = -5.140336158145698e+17;
        bool r19277652 = r19277650 <= r19277651;
        double r19277653 = 4.16438922228;
        double r19277654 = y;
        double r19277655 = r19277654 / r19277650;
        double r19277656 = r19277655 / r19277650;
        double r19277657 = fma(r19277650, r19277653, r19277656);
        double r19277658 = 110.1139242984811;
        double r19277659 = r19277657 - r19277658;
        double r19277660 = 1.692613215272597e+44;
        bool r19277661 = r19277650 <= r19277660;
        double r19277662 = 78.6994924154;
        double r19277663 = fma(r19277653, r19277650, r19277662);
        double r19277664 = 137.519416416;
        double r19277665 = fma(r19277663, r19277650, r19277664);
        double r19277666 = fma(r19277650, r19277665, r19277654);
        double r19277667 = z;
        double r19277668 = fma(r19277666, r19277650, r19277667);
        double r19277669 = 43.3400022514;
        double r19277670 = r19277650 + r19277669;
        double r19277671 = 263.505074721;
        double r19277672 = fma(r19277670, r19277650, r19277671);
        double r19277673 = 313.399215894;
        double r19277674 = fma(r19277672, r19277650, r19277673);
        double r19277675 = 47.066876606;
        double r19277676 = fma(r19277674, r19277650, r19277675);
        double r19277677 = 3.0;
        double r19277678 = pow(r19277650, r19277677);
        double r19277679 = 2.0;
        double r19277680 = r19277679 * r19277679;
        double r19277681 = r19277680 * r19277679;
        double r19277682 = r19277678 - r19277681;
        double r19277683 = r19277676 / r19277682;
        double r19277684 = r19277668 / r19277683;
        double r19277685 = r19277679 * r19277650;
        double r19277686 = r19277685 + r19277680;
        double r19277687 = r19277650 * r19277650;
        double r19277688 = r19277686 + r19277687;
        double r19277689 = r19277684 / r19277688;
        double r19277690 = r19277661 ? r19277689 : r19277659;
        double r19277691 = r19277652 ? r19277659 : r19277690;
        return r19277691;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original26.0
Target0.4
Herbie0.8
\[\begin{array}{l} \mathbf{if}\;x \lt -3.326128725870005 \cdot 10^{+62}:\\ \;\;\;\;\left(\frac{y}{x \cdot x} + 4.16438922228 \cdot x\right) - 110.1139242984811\\ \mathbf{elif}\;x \lt 9.429991714554673 \cdot 10^{+55}:\\ \;\;\;\;\frac{x - 2.0}{1} \cdot \frac{\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z}{\left(\left(263.505074721 \cdot x + \left(43.3400022514 \cdot \left(x \cdot x\right) + x \cdot \left(x \cdot x\right)\right)\right) + 313.399215894\right) \cdot x + 47.066876606}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{y}{x \cdot x} + 4.16438922228 \cdot x\right) - 110.1139242984811\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -5.140336158145698e+17 or 1.692613215272597e+44 < x

    1. Initial program 56.2

      \[\frac{\left(x - 2.0\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606}\]
    2. Simplified52.9

      \[\leadsto \color{blue}{\left(x - 2.0\right) \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), y\right), z\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}}\]
    3. Taylor expanded around inf 1.3

      \[\leadsto \color{blue}{\left(\frac{y}{{x}^{2}} + 4.16438922228 \cdot x\right) - 110.1139242984811}\]
    4. Simplified1.3

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 4.16438922228, \frac{\frac{y}{x}}{x}\right) - 110.1139242984811}\]

    if -5.140336158145698e+17 < x < 1.692613215272597e+44

    1. Initial program 0.7

      \[\frac{\left(x - 2.0\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606}\]
    2. Simplified0.3

      \[\leadsto \color{blue}{\left(x - 2.0\right) \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), y\right), z\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}}\]
    3. Using strategy rm
    4. Applied fma-udef0.3

      \[\leadsto \left(x - 2.0\right) \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), y\right), z\right)}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right) \cdot x + 313.399215894}, x, 47.066876606\right)}\]
    5. Using strategy rm
    6. Applied flip3--0.3

      \[\leadsto \color{blue}{\frac{{x}^{3} - {2.0}^{3}}{x \cdot x + \left(2.0 \cdot 2.0 + x \cdot 2.0\right)}} \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), y\right), z\right)}{\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right) \cdot x + 313.399215894, x, 47.066876606\right)}\]
    7. Applied associate-*l/0.3

      \[\leadsto \color{blue}{\frac{\left({x}^{3} - {2.0}^{3}\right) \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), y\right), z\right)}{\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right) \cdot x + 313.399215894, x, 47.066876606\right)}}{x \cdot x + \left(2.0 \cdot 2.0 + x \cdot 2.0\right)}}\]
    8. Simplified0.3

      \[\leadsto \frac{\color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(4.16438922228, x, 78.6994924154\right), x, 137.519416416\right), y\right), x, z\right)}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}{x \cdot \left(x \cdot x\right) - \left(2.0 \cdot 2.0\right) \cdot 2.0}}}}{x \cdot x + \left(2.0 \cdot 2.0 + x \cdot 2.0\right)}\]
    9. Using strategy rm
    10. Applied pow10.3

      \[\leadsto \frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(4.16438922228, x, 78.6994924154\right), x, 137.519416416\right), y\right), x, z\right)}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}{x \cdot \left(x \cdot \color{blue}{{x}^{1}}\right) - \left(2.0 \cdot 2.0\right) \cdot 2.0}}}{x \cdot x + \left(2.0 \cdot 2.0 + x \cdot 2.0\right)}\]
    11. Applied pow10.3

      \[\leadsto \frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(4.16438922228, x, 78.6994924154\right), x, 137.519416416\right), y\right), x, z\right)}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}{x \cdot \left(\color{blue}{{x}^{1}} \cdot {x}^{1}\right) - \left(2.0 \cdot 2.0\right) \cdot 2.0}}}{x \cdot x + \left(2.0 \cdot 2.0 + x \cdot 2.0\right)}\]
    12. Applied pow-prod-up0.3

      \[\leadsto \frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(4.16438922228, x, 78.6994924154\right), x, 137.519416416\right), y\right), x, z\right)}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}{x \cdot \color{blue}{{x}^{\left(1 + 1\right)}} - \left(2.0 \cdot 2.0\right) \cdot 2.0}}}{x \cdot x + \left(2.0 \cdot 2.0 + x \cdot 2.0\right)}\]
    13. Applied pow10.3

      \[\leadsto \frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(4.16438922228, x, 78.6994924154\right), x, 137.519416416\right), y\right), x, z\right)}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}{\color{blue}{{x}^{1}} \cdot {x}^{\left(1 + 1\right)} - \left(2.0 \cdot 2.0\right) \cdot 2.0}}}{x \cdot x + \left(2.0 \cdot 2.0 + x \cdot 2.0\right)}\]
    14. Applied pow-prod-up0.3

      \[\leadsto \frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(4.16438922228, x, 78.6994924154\right), x, 137.519416416\right), y\right), x, z\right)}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}{\color{blue}{{x}^{\left(1 + \left(1 + 1\right)\right)}} - \left(2.0 \cdot 2.0\right) \cdot 2.0}}}{x \cdot x + \left(2.0 \cdot 2.0 + x \cdot 2.0\right)}\]
    15. Simplified0.3

      \[\leadsto \frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(4.16438922228, x, 78.6994924154\right), x, 137.519416416\right), y\right), x, z\right)}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}{{x}^{\color{blue}{3}} - \left(2.0 \cdot 2.0\right) \cdot 2.0}}}{x \cdot x + \left(2.0 \cdot 2.0 + x \cdot 2.0\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -5.140336158145698 \cdot 10^{+17}:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922228, \frac{\frac{y}{x}}{x}\right) - 110.1139242984811\\ \mathbf{elif}\;x \le 1.692613215272597 \cdot 10^{+44}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(4.16438922228, x, 78.6994924154\right), x, 137.519416416\right), y\right), x, z\right)}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}{{x}^{3} - \left(2.0 \cdot 2.0\right) \cdot 2.0}}}{\left(2.0 \cdot x + 2.0 \cdot 2.0\right) + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922228, \frac{\frac{y}{x}}{x}\right) - 110.1139242984811\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< x -3.326128725870005e+62) (- (+ (/ y (* x x)) (* 4.16438922228 x)) 110.1139242984811) (if (< x 9.429991714554673e+55) (* (/ (- x 2.0) 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.0) (+ (* (+ (* (+ (* (+ (* x 4.16438922228) 78.6994924154) x) 137.519416416) x) y) x) z)) (+ (* (+ (* (+ (* (+ x 43.3400022514) x) 263.505074721) x) 313.399215894) x) 47.066876606)))