Average Error: 27.5 → 0.6
Time: 8.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 -3.2249422671409879 \cdot 10^{47} \lor \neg \left(x \le 3.6379943132031436 \cdot 10^{44}\right):\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}} - 110.113924298481081\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) \cdot \left(x + 2\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)}}\\ \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 -3.2249422671409879 \cdot 10^{47} \lor \neg \left(x \le 3.6379943132031436 \cdot 10^{44}\right):\\
\;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}} - 110.113924298481081\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) \cdot \left(x + 2\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)}}\\

\end{array}
double f(double x, double y, double z) {
        double r331043 = x;
        double r331044 = 2.0;
        double r331045 = r331043 - r331044;
        double r331046 = 4.16438922228;
        double r331047 = r331043 * r331046;
        double r331048 = 78.6994924154;
        double r331049 = r331047 + r331048;
        double r331050 = r331049 * r331043;
        double r331051 = 137.519416416;
        double r331052 = r331050 + r331051;
        double r331053 = r331052 * r331043;
        double r331054 = y;
        double r331055 = r331053 + r331054;
        double r331056 = r331055 * r331043;
        double r331057 = z;
        double r331058 = r331056 + r331057;
        double r331059 = r331045 * r331058;
        double r331060 = 43.3400022514;
        double r331061 = r331043 + r331060;
        double r331062 = r331061 * r331043;
        double r331063 = 263.505074721;
        double r331064 = r331062 + r331063;
        double r331065 = r331064 * r331043;
        double r331066 = 313.399215894;
        double r331067 = r331065 + r331066;
        double r331068 = r331067 * r331043;
        double r331069 = 47.066876606;
        double r331070 = r331068 + r331069;
        double r331071 = r331059 / r331070;
        return r331071;
}

double f(double x, double y, double z) {
        double r331072 = x;
        double r331073 = -3.224942267140988e+47;
        bool r331074 = r331072 <= r331073;
        double r331075 = 3.6379943132031436e+44;
        bool r331076 = r331072 <= r331075;
        double r331077 = !r331076;
        bool r331078 = r331074 || r331077;
        double r331079 = 4.16438922228;
        double r331080 = y;
        double r331081 = 2.0;
        double r331082 = pow(r331072, r331081);
        double r331083 = r331080 / r331082;
        double r331084 = 110.11392429848108;
        double r331085 = r331083 - r331084;
        double r331086 = fma(r331072, r331079, r331085);
        double r331087 = r331072 * r331072;
        double r331088 = 2.0;
        double r331089 = r331088 * r331088;
        double r331090 = r331087 - r331089;
        double r331091 = 43.3400022514;
        double r331092 = r331072 + r331091;
        double r331093 = 263.505074721;
        double r331094 = fma(r331092, r331072, r331093);
        double r331095 = 313.399215894;
        double r331096 = fma(r331094, r331072, r331095);
        double r331097 = 47.066876606;
        double r331098 = fma(r331096, r331072, r331097);
        double r331099 = r331072 + r331088;
        double r331100 = r331098 * r331099;
        double r331101 = 78.6994924154;
        double r331102 = fma(r331072, r331079, r331101);
        double r331103 = 137.519416416;
        double r331104 = fma(r331102, r331072, r331103);
        double r331105 = fma(r331104, r331072, r331080);
        double r331106 = z;
        double r331107 = fma(r331105, r331072, r331106);
        double r331108 = r331100 / r331107;
        double r331109 = r331090 / r331108;
        double r331110 = r331078 ? r331086 : r331109;
        return r331110;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original27.5
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 < -3.224942267140988e+47 or 3.6379943132031436e+44 < x

    1. Initial program 61.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. Simplified58.1

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

      \[\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/58.1

      \[\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. Taylor expanded around inf 0.5

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

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

    if -3.224942267140988e+47 < x < 3.6379943132031436e+44

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

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

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

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

      \[\leadsto \frac{x \cdot x - 2 \cdot 2}{\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) \cdot \left(x + 2\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. Recombined 2 regimes into one program.
  4. Final simplification0.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -3.2249422671409879 \cdot 10^{47} \lor \neg \left(x \le 3.6379943132031436 \cdot 10^{44}\right):\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}} - 110.113924298481081\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) \cdot \left(x + 2\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)}}\\ \end{array}\]

Reproduce

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