Average Error: 26.9 → 0.7
Time: 7.1s
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 -2.54463890534666934 \cdot 10^{39} \lor \neg \left(x \le 8.0836994708554476 \cdot 10^{49}\right):\\ \;\;\;\;\left(x - 2\right) \cdot \left(\left(\frac{y}{{x}^{3}} + 4.16438922227999964\right) - 101.785145853921094 \cdot \frac{1}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - 2\right) \cdot \frac{1 \cdot \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)}{\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 -2.54463890534666934 \cdot 10^{39} \lor \neg \left(x \le 8.0836994708554476 \cdot 10^{49}\right):\\
\;\;\;\;\left(x - 2\right) \cdot \left(\left(\frac{y}{{x}^{3}} + 4.16438922227999964\right) - 101.785145853921094 \cdot \frac{1}{x}\right)\\

\mathbf{else}:\\
\;\;\;\;\left(x - 2\right) \cdot \frac{1 \cdot \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)}{\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 r368220 = x;
        double r368221 = 2.0;
        double r368222 = r368220 - r368221;
        double r368223 = 4.16438922228;
        double r368224 = r368220 * r368223;
        double r368225 = 78.6994924154;
        double r368226 = r368224 + r368225;
        double r368227 = r368226 * r368220;
        double r368228 = 137.519416416;
        double r368229 = r368227 + r368228;
        double r368230 = r368229 * r368220;
        double r368231 = y;
        double r368232 = r368230 + r368231;
        double r368233 = r368232 * r368220;
        double r368234 = z;
        double r368235 = r368233 + r368234;
        double r368236 = r368222 * r368235;
        double r368237 = 43.3400022514;
        double r368238 = r368220 + r368237;
        double r368239 = r368238 * r368220;
        double r368240 = 263.505074721;
        double r368241 = r368239 + r368240;
        double r368242 = r368241 * r368220;
        double r368243 = 313.399215894;
        double r368244 = r368242 + r368243;
        double r368245 = r368244 * r368220;
        double r368246 = 47.066876606;
        double r368247 = r368245 + r368246;
        double r368248 = r368236 / r368247;
        return r368248;
}

double f(double x, double y, double z) {
        double r368249 = x;
        double r368250 = -2.5446389053466693e+39;
        bool r368251 = r368249 <= r368250;
        double r368252 = 8.083699470855448e+49;
        bool r368253 = r368249 <= r368252;
        double r368254 = !r368253;
        bool r368255 = r368251 || r368254;
        double r368256 = 2.0;
        double r368257 = r368249 - r368256;
        double r368258 = y;
        double r368259 = 3.0;
        double r368260 = pow(r368249, r368259);
        double r368261 = r368258 / r368260;
        double r368262 = 4.16438922228;
        double r368263 = r368261 + r368262;
        double r368264 = 101.7851458539211;
        double r368265 = 1.0;
        double r368266 = r368265 / r368249;
        double r368267 = r368264 * r368266;
        double r368268 = r368263 - r368267;
        double r368269 = r368257 * r368268;
        double r368270 = 78.6994924154;
        double r368271 = fma(r368249, r368262, r368270);
        double r368272 = 137.519416416;
        double r368273 = fma(r368271, r368249, r368272);
        double r368274 = fma(r368273, r368249, r368258);
        double r368275 = z;
        double r368276 = fma(r368274, r368249, r368275);
        double r368277 = r368265 * r368276;
        double r368278 = 43.3400022514;
        double r368279 = r368249 + r368278;
        double r368280 = 263.505074721;
        double r368281 = fma(r368279, r368249, r368280);
        double r368282 = 313.399215894;
        double r368283 = fma(r368281, r368249, r368282);
        double r368284 = 47.066876606;
        double r368285 = fma(r368283, r368249, r368284);
        double r368286 = r368277 / r368285;
        double r368287 = r368257 * r368286;
        double r368288 = r368255 ? r368269 : r368287;
        return r368288;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original26.9
Target0.5
Herbie0.7
\[\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 < -2.5446389053466693e+39 or 8.083699470855448e+49 < x

    1. Initial program 61.0

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

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

      \[\leadsto \frac{x - 2}{\frac{\mathsf{fma}\left(\color{blue}{{\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right)\right)}^{1}}, 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. Using strategy rm
    6. Applied div-inv56.7

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

      \[\leadsto \left(x - 2\right) \cdot \color{blue}{\frac{1 \cdot \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)}{\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. Using strategy rm
    9. Applied add-sqr-sqrt56.7

      \[\leadsto \left(x - 2\right) \cdot \frac{1 \cdot \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}{\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)}}}\]
    10. Applied times-frac56.7

      \[\leadsto \left(x - 2\right) \cdot \color{blue}{\left(\frac{1}{\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{\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)}}\right)}\]
    11. Taylor expanded around inf 0.9

      \[\leadsto \left(x - 2\right) \cdot \color{blue}{\left(\left(\frac{y}{{x}^{3}} + 4.16438922227999964\right) - 101.785145853921094 \cdot \frac{1}{x}\right)}\]

    if -2.5446389053466693e+39 < x < 8.083699470855448e+49

    1. Initial program 1.0

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

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

      \[\leadsto \frac{x - 2}{\frac{\mathsf{fma}\left(\color{blue}{{\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right)\right)}^{1}}, 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. Using strategy rm
    6. Applied div-inv0.7

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

      \[\leadsto \left(x - 2\right) \cdot \color{blue}{\frac{1 \cdot \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)}{\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.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.54463890534666934 \cdot 10^{39} \lor \neg \left(x \le 8.0836994708554476 \cdot 10^{49}\right):\\ \;\;\;\;\left(x - 2\right) \cdot \left(\left(\frac{y}{{x}^{3}} + 4.16438922227999964\right) - 101.785145853921094 \cdot \frac{1}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - 2\right) \cdot \frac{1 \cdot \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)}{\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 2020021 +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)))