Average Error: 26.3 → 0.8
Time: 14.4s
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 r391189 = x;
        double r391190 = 2.0;
        double r391191 = r391189 - r391190;
        double r391192 = 4.16438922228;
        double r391193 = r391189 * r391192;
        double r391194 = 78.6994924154;
        double r391195 = r391193 + r391194;
        double r391196 = r391195 * r391189;
        double r391197 = 137.519416416;
        double r391198 = r391196 + r391197;
        double r391199 = r391198 * r391189;
        double r391200 = y;
        double r391201 = r391199 + r391200;
        double r391202 = r391201 * r391189;
        double r391203 = z;
        double r391204 = r391202 + r391203;
        double r391205 = r391191 * r391204;
        double r391206 = 43.3400022514;
        double r391207 = r391189 + r391206;
        double r391208 = r391207 * r391189;
        double r391209 = 263.505074721;
        double r391210 = r391208 + r391209;
        double r391211 = r391210 * r391189;
        double r391212 = 313.399215894;
        double r391213 = r391211 + r391212;
        double r391214 = r391213 * r391189;
        double r391215 = 47.066876606;
        double r391216 = r391214 + r391215;
        double r391217 = r391205 / r391216;
        return r391217;
}

double f(double x, double y, double z) {
        double r391218 = x;
        double r391219 = -5.0183641578968565e+54;
        bool r391220 = r391218 <= r391219;
        double r391221 = 6.950586002949617e+46;
        bool r391222 = r391218 <= r391221;
        double r391223 = !r391222;
        bool r391224 = r391220 || r391223;
        double r391225 = 4.16438922228;
        double r391226 = y;
        double r391227 = 2.0;
        double r391228 = pow(r391218, r391227);
        double r391229 = r391226 / r391228;
        double r391230 = fma(r391218, r391225, r391229);
        double r391231 = 110.1139242984811;
        double r391232 = r391230 - r391231;
        double r391233 = 78.6994924154;
        double r391234 = fma(r391218, r391225, r391233);
        double r391235 = 137.519416416;
        double r391236 = fma(r391234, r391218, r391235);
        double r391237 = fma(r391236, r391218, r391226);
        double r391238 = z;
        double r391239 = fma(r391237, r391218, r391238);
        double r391240 = 43.3400022514;
        double r391241 = r391218 + r391240;
        double r391242 = 263.505074721;
        double r391243 = fma(r391241, r391218, r391242);
        double r391244 = 313.399215894;
        double r391245 = fma(r391243, r391218, r391244);
        double r391246 = 47.066876606;
        double r391247 = fma(r391245, r391218, r391246);
        double r391248 = sqrt(r391247);
        double r391249 = r391239 / r391248;
        double r391250 = 3.0;
        double r391251 = pow(r391218, r391250);
        double r391252 = 2.0;
        double r391253 = pow(r391252, r391250);
        double r391254 = r391251 - r391253;
        double r391255 = r391218 + r391252;
        double r391256 = r391252 * r391255;
        double r391257 = fma(r391218, r391218, r391256);
        double r391258 = r391257 * r391248;
        double r391259 = r391254 / r391258;
        double r391260 = r391249 * r391259;
        double r391261 = r391224 ? r391232 : r391260;
        return r391261;
}

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. Using strategy rm
    4. Applied *-un-lft-identity61.8

      \[\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}{1 \cdot \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-frac58.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)}{1} \cdot \frac{x - 2}{\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. Simplified58.1

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

      \[\leadsto \color{blue}{\left(\frac{y}{{x}^{2}} + 4.16438922227999964 \cdot x\right) - 110.11392429848109}\]
    8. 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)))