Average Error: 27.3 → 0.6
Time: 8.9s
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 -4.79056009323469059 \cdot 10^{75} \lor \neg \left(x \le 4.21871492436040422 \cdot 10^{50}\right):\\ \;\;\;\;1 \cdot \left(\left(x - 2\right) \cdot \left(\left(\frac{y}{{x}^{3}} + 4.16438922227999964\right) - 101.785145853921094 \cdot \frac{1}{x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \left(\left(x - 2\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)}{\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)\\ \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 -4.79056009323469059 \cdot 10^{75} \lor \neg \left(x \le 4.21871492436040422 \cdot 10^{50}\right):\\
\;\;\;\;1 \cdot \left(\left(x - 2\right) \cdot \left(\left(\frac{y}{{x}^{3}} + 4.16438922227999964\right) - 101.785145853921094 \cdot \frac{1}{x}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;1 \cdot \left(\left(x - 2\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)}{\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)\\

\end{array}
double f(double x, double y, double z) {
        double r313254 = x;
        double r313255 = 2.0;
        double r313256 = r313254 - r313255;
        double r313257 = 4.16438922228;
        double r313258 = r313254 * r313257;
        double r313259 = 78.6994924154;
        double r313260 = r313258 + r313259;
        double r313261 = r313260 * r313254;
        double r313262 = 137.519416416;
        double r313263 = r313261 + r313262;
        double r313264 = r313263 * r313254;
        double r313265 = y;
        double r313266 = r313264 + r313265;
        double r313267 = r313266 * r313254;
        double r313268 = z;
        double r313269 = r313267 + r313268;
        double r313270 = r313256 * r313269;
        double r313271 = 43.3400022514;
        double r313272 = r313254 + r313271;
        double r313273 = r313272 * r313254;
        double r313274 = 263.505074721;
        double r313275 = r313273 + r313274;
        double r313276 = r313275 * r313254;
        double r313277 = 313.399215894;
        double r313278 = r313276 + r313277;
        double r313279 = r313278 * r313254;
        double r313280 = 47.066876606;
        double r313281 = r313279 + r313280;
        double r313282 = r313270 / r313281;
        return r313282;
}

double f(double x, double y, double z) {
        double r313283 = x;
        double r313284 = -4.7905600932346906e+75;
        bool r313285 = r313283 <= r313284;
        double r313286 = 4.218714924360404e+50;
        bool r313287 = r313283 <= r313286;
        double r313288 = !r313287;
        bool r313289 = r313285 || r313288;
        double r313290 = 1.0;
        double r313291 = 2.0;
        double r313292 = r313283 - r313291;
        double r313293 = y;
        double r313294 = 3.0;
        double r313295 = pow(r313283, r313294);
        double r313296 = r313293 / r313295;
        double r313297 = 4.16438922228;
        double r313298 = r313296 + r313297;
        double r313299 = 101.7851458539211;
        double r313300 = r313290 / r313283;
        double r313301 = r313299 * r313300;
        double r313302 = r313298 - r313301;
        double r313303 = r313292 * r313302;
        double r313304 = r313290 * r313303;
        double r313305 = 78.6994924154;
        double r313306 = fma(r313283, r313297, r313305);
        double r313307 = 137.519416416;
        double r313308 = fma(r313306, r313283, r313307);
        double r313309 = fma(r313308, r313283, r313293);
        double r313310 = z;
        double r313311 = fma(r313309, r313283, r313310);
        double r313312 = 43.3400022514;
        double r313313 = r313283 + r313312;
        double r313314 = 263.505074721;
        double r313315 = fma(r313313, r313283, r313314);
        double r313316 = 313.399215894;
        double r313317 = fma(r313315, r313283, r313316);
        double r313318 = 47.066876606;
        double r313319 = fma(r313317, r313283, r313318);
        double r313320 = r313311 / r313319;
        double r313321 = r313292 * r313320;
        double r313322 = r313290 * r313321;
        double r313323 = r313289 ? r313304 : r313322;
        return r313323;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original27.3
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 < -4.7905600932346906e+75 or 4.218714924360404e+50 < x

    1. Initial program 62.9

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

      \[\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 clear-num60.8

      \[\leadsto \frac{x - 2}{\color{blue}{\frac{1}{\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)}{\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. Using strategy rm
    6. Applied *-un-lft-identity60.8

      \[\leadsto \frac{x - 2}{\frac{1}{\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}{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)}}}}\]
    7. Applied *-un-lft-identity60.8

      \[\leadsto \frac{x - 2}{\frac{1}{\frac{\color{blue}{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)}}{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)}}}\]
    8. Applied times-frac60.8

      \[\leadsto \frac{x - 2}{\frac{1}{\color{blue}{\frac{1}{1} \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)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}}}\]
    9. Applied add-sqr-sqrt60.8

      \[\leadsto \frac{x - 2}{\frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}}}{\frac{1}{1} \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)}{\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-frac60.8

      \[\leadsto \frac{x - 2}{\color{blue}{\frac{\sqrt{1}}{\frac{1}{1}} \cdot \frac{\sqrt{1}}{\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)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}}}\]
    11. Applied *-un-lft-identity60.8

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x - 2\right)}}{\frac{\sqrt{1}}{\frac{1}{1}} \cdot \frac{\sqrt{1}}{\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)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}}\]
    12. Applied times-frac60.8

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

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

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

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

    if -4.7905600932346906e+75 < x < 4.218714924360404e+50

    1. Initial program 2.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.8

      \[\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 clear-num0.8

      \[\leadsto \frac{x - 2}{\color{blue}{\frac{1}{\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)}{\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. Using strategy rm
    6. Applied *-un-lft-identity0.8

      \[\leadsto \frac{x - 2}{\frac{1}{\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}{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)}}}}\]
    7. Applied *-un-lft-identity0.8

      \[\leadsto \frac{x - 2}{\frac{1}{\frac{\color{blue}{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)}}{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)}}}\]
    8. Applied times-frac0.8

      \[\leadsto \frac{x - 2}{\frac{1}{\color{blue}{\frac{1}{1} \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)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}}}\]
    9. Applied add-sqr-sqrt0.8

      \[\leadsto \frac{x - 2}{\frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}}}{\frac{1}{1} \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)}{\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-frac0.8

      \[\leadsto \frac{x - 2}{\color{blue}{\frac{\sqrt{1}}{\frac{1}{1}} \cdot \frac{\sqrt{1}}{\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)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}}}\]
    11. Applied *-un-lft-identity0.8

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x - 2\right)}}{\frac{\sqrt{1}}{\frac{1}{1}} \cdot \frac{\sqrt{1}}{\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)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}}\]
    12. Applied times-frac0.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -4.79056009323469059 \cdot 10^{75} \lor \neg \left(x \le 4.21871492436040422 \cdot 10^{50}\right):\\ \;\;\;\;1 \cdot \left(\left(x - 2\right) \cdot \left(\left(\frac{y}{{x}^{3}} + 4.16438922227999964\right) - 101.785145853921094 \cdot \frac{1}{x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \left(\left(x - 2\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)}{\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)\\ \end{array}\]

Reproduce

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