Average Error: 26.8 → 0.8
Time: 21.8s
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.7633448860088183 \cdot 10^{26} \lor \neg \left(x \le 6.1474264141626379 \cdot 10^{26}\right):\\ \;\;\;\;\mathsf{fma}\left(4.16438922227999964, x, \frac{y}{{x}^{2}}\right) - 110.11392429848109\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\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)}{\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)}{{x}^{3} - {2}^{3}}}}{\sqrt{\mathsf{fma}\left(x, x, 2 \cdot \left(2 + x\right)\right)}}}{\sqrt{x \cdot x + \left(2 \cdot 2 + x \cdot 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 -5.7633448860088183 \cdot 10^{26} \lor \neg \left(x \le 6.1474264141626379 \cdot 10^{26}\right):\\
\;\;\;\;\mathsf{fma}\left(4.16438922227999964, x, \frac{y}{{x}^{2}}\right) - 110.11392429848109\\

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

\end{array}
double f(double x, double y, double z) {
        double r493957 = x;
        double r493958 = 2.0;
        double r493959 = r493957 - r493958;
        double r493960 = 4.16438922228;
        double r493961 = r493957 * r493960;
        double r493962 = 78.6994924154;
        double r493963 = r493961 + r493962;
        double r493964 = r493963 * r493957;
        double r493965 = 137.519416416;
        double r493966 = r493964 + r493965;
        double r493967 = r493966 * r493957;
        double r493968 = y;
        double r493969 = r493967 + r493968;
        double r493970 = r493969 * r493957;
        double r493971 = z;
        double r493972 = r493970 + r493971;
        double r493973 = r493959 * r493972;
        double r493974 = 43.3400022514;
        double r493975 = r493957 + r493974;
        double r493976 = r493975 * r493957;
        double r493977 = 263.505074721;
        double r493978 = r493976 + r493977;
        double r493979 = r493978 * r493957;
        double r493980 = 313.399215894;
        double r493981 = r493979 + r493980;
        double r493982 = r493981 * r493957;
        double r493983 = 47.066876606;
        double r493984 = r493982 + r493983;
        double r493985 = r493973 / r493984;
        return r493985;
}

double f(double x, double y, double z) {
        double r493986 = x;
        double r493987 = -5.763344886008818e+26;
        bool r493988 = r493986 <= r493987;
        double r493989 = 6.147426414162638e+26;
        bool r493990 = r493986 <= r493989;
        double r493991 = !r493990;
        bool r493992 = r493988 || r493991;
        double r493993 = 4.16438922228;
        double r493994 = y;
        double r493995 = 2.0;
        double r493996 = pow(r493986, r493995);
        double r493997 = r493994 / r493996;
        double r493998 = fma(r493993, r493986, r493997);
        double r493999 = 110.1139242984811;
        double r494000 = r493998 - r493999;
        double r494001 = 78.6994924154;
        double r494002 = fma(r493986, r493993, r494001);
        double r494003 = 137.519416416;
        double r494004 = fma(r494002, r493986, r494003);
        double r494005 = fma(r494004, r493986, r493994);
        double r494006 = z;
        double r494007 = fma(r494005, r493986, r494006);
        double r494008 = 43.3400022514;
        double r494009 = r493986 + r494008;
        double r494010 = 263.505074721;
        double r494011 = fma(r494009, r493986, r494010);
        double r494012 = 313.399215894;
        double r494013 = fma(r494011, r493986, r494012);
        double r494014 = 47.066876606;
        double r494015 = fma(r494013, r493986, r494014);
        double r494016 = 3.0;
        double r494017 = pow(r493986, r494016);
        double r494018 = 2.0;
        double r494019 = pow(r494018, r494016);
        double r494020 = r494017 - r494019;
        double r494021 = r494015 / r494020;
        double r494022 = r494007 / r494021;
        double r494023 = r494018 + r493986;
        double r494024 = r494018 * r494023;
        double r494025 = fma(r493986, r493986, r494024);
        double r494026 = sqrt(r494025);
        double r494027 = r494022 / r494026;
        double r494028 = r493986 * r493986;
        double r494029 = r494018 * r494018;
        double r494030 = r493986 * r494018;
        double r494031 = r494029 + r494030;
        double r494032 = r494028 + r494031;
        double r494033 = sqrt(r494032);
        double r494034 = r494027 / r494033;
        double r494035 = r493992 ? r494000 : r494034;
        return r494035;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original26.8
Target0.5
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.763344886008818e+26 or 6.147426414162638e+26 < x

    1. Initial program 57.5

      \[\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. Simplified57.5

      \[\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 1.5

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

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

    if -5.763344886008818e+26 < x < 6.147426414162638e+26

    1. Initial program 0.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.6

      \[\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 associate-/l*0.3

      \[\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)}{\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)}{x - 2}}}\]
    5. Using strategy rm
    6. Applied flip3--0.3

      \[\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)}{\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)}{\color{blue}{\frac{{x}^{3} - {2}^{3}}{x \cdot x + \left(2 \cdot 2 + x \cdot 2\right)}}}}\]
    7. Applied associate-/r/0.3

      \[\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)}{\color{blue}{\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)}{{x}^{3} - {2}^{3}} \cdot \left(x \cdot x + \left(2 \cdot 2 + x \cdot 2\right)\right)}}\]
    8. Applied associate-/r*0.3

      \[\leadsto \color{blue}{\frac{\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)}{\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)}{{x}^{3} - {2}^{3}}}}{x \cdot x + \left(2 \cdot 2 + x \cdot 2\right)}}\]
    9. Using strategy rm
    10. Applied add-sqr-sqrt0.3

      \[\leadsto \frac{\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)}{\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)}{{x}^{3} - {2}^{3}}}}{\color{blue}{\sqrt{x \cdot x + \left(2 \cdot 2 + x \cdot 2\right)} \cdot \sqrt{x \cdot x + \left(2 \cdot 2 + x \cdot 2\right)}}}\]
    11. Applied associate-/r*0.3

      \[\leadsto \color{blue}{\frac{\frac{\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)}{\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)}{{x}^{3} - {2}^{3}}}}{\sqrt{x \cdot x + \left(2 \cdot 2 + x \cdot 2\right)}}}{\sqrt{x \cdot x + \left(2 \cdot 2 + x \cdot 2\right)}}}\]
    12. Simplified0.3

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

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

Reproduce

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