Average Error: 25.3 → 0.9
Time: 35.9s
Precision: 64
\[\frac{\left(x - 2.0\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.0082194143627248 \cdot 10^{+25}:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922228, \frac{y}{x \cdot x}\right) - 110.1139242984811\\ \mathbf{elif}\;x \le 1.3289883024938852 \cdot 10^{+23}:\\ \;\;\;\;\left(x - 2.0\right) \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(4.16438922228, x, 78.6994924154\right), x, 137.519416416\right), y\right), z\right)}{\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), 47.066876606\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922228, \frac{y}{x \cdot x}\right) - 110.1139242984811\\ \end{array}\]
\frac{\left(x - 2.0\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606}
\begin{array}{l}
\mathbf{if}\;x \le -1.0082194143627248 \cdot 10^{+25}:\\
\;\;\;\;\mathsf{fma}\left(x, 4.16438922228, \frac{y}{x \cdot x}\right) - 110.1139242984811\\

\mathbf{elif}\;x \le 1.3289883024938852 \cdot 10^{+23}:\\
\;\;\;\;\left(x - 2.0\right) \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(4.16438922228, x, 78.6994924154\right), x, 137.519416416\right), y\right), z\right)}{\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), 47.066876606\right)}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, 4.16438922228, \frac{y}{x \cdot x}\right) - 110.1139242984811\\

\end{array}
double f(double x, double y, double z) {
        double r17201084 = x;
        double r17201085 = 2.0;
        double r17201086 = r17201084 - r17201085;
        double r17201087 = 4.16438922228;
        double r17201088 = r17201084 * r17201087;
        double r17201089 = 78.6994924154;
        double r17201090 = r17201088 + r17201089;
        double r17201091 = r17201090 * r17201084;
        double r17201092 = 137.519416416;
        double r17201093 = r17201091 + r17201092;
        double r17201094 = r17201093 * r17201084;
        double r17201095 = y;
        double r17201096 = r17201094 + r17201095;
        double r17201097 = r17201096 * r17201084;
        double r17201098 = z;
        double r17201099 = r17201097 + r17201098;
        double r17201100 = r17201086 * r17201099;
        double r17201101 = 43.3400022514;
        double r17201102 = r17201084 + r17201101;
        double r17201103 = r17201102 * r17201084;
        double r17201104 = 263.505074721;
        double r17201105 = r17201103 + r17201104;
        double r17201106 = r17201105 * r17201084;
        double r17201107 = 313.399215894;
        double r17201108 = r17201106 + r17201107;
        double r17201109 = r17201108 * r17201084;
        double r17201110 = 47.066876606;
        double r17201111 = r17201109 + r17201110;
        double r17201112 = r17201100 / r17201111;
        return r17201112;
}

double f(double x, double y, double z) {
        double r17201113 = x;
        double r17201114 = -1.0082194143627248e+25;
        bool r17201115 = r17201113 <= r17201114;
        double r17201116 = 4.16438922228;
        double r17201117 = y;
        double r17201118 = r17201113 * r17201113;
        double r17201119 = r17201117 / r17201118;
        double r17201120 = fma(r17201113, r17201116, r17201119);
        double r17201121 = 110.1139242984811;
        double r17201122 = r17201120 - r17201121;
        double r17201123 = 1.3289883024938852e+23;
        bool r17201124 = r17201113 <= r17201123;
        double r17201125 = 2.0;
        double r17201126 = r17201113 - r17201125;
        double r17201127 = 78.6994924154;
        double r17201128 = fma(r17201116, r17201113, r17201127);
        double r17201129 = 137.519416416;
        double r17201130 = fma(r17201128, r17201113, r17201129);
        double r17201131 = fma(r17201113, r17201130, r17201117);
        double r17201132 = z;
        double r17201133 = fma(r17201113, r17201131, r17201132);
        double r17201134 = 43.3400022514;
        double r17201135 = r17201113 + r17201134;
        double r17201136 = 263.505074721;
        double r17201137 = fma(r17201135, r17201113, r17201136);
        double r17201138 = 313.399215894;
        double r17201139 = fma(r17201137, r17201113, r17201138);
        double r17201140 = 47.066876606;
        double r17201141 = fma(r17201113, r17201139, r17201140);
        double r17201142 = r17201133 / r17201141;
        double r17201143 = r17201126 * r17201142;
        double r17201144 = r17201124 ? r17201143 : r17201122;
        double r17201145 = r17201115 ? r17201122 : r17201144;
        return r17201145;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original25.3
Target0.5
Herbie0.9
\[\begin{array}{l} \mathbf{if}\;x \lt -3.326128725870005 \cdot 10^{+62}:\\ \;\;\;\;\left(\frac{y}{x \cdot x} + 4.16438922228 \cdot x\right) - 110.1139242984811\\ \mathbf{elif}\;x \lt 9.429991714554673 \cdot 10^{+55}:\\ \;\;\;\;\frac{x - 2.0}{1} \cdot \frac{\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z}{\left(\left(263.505074721 \cdot x + \left(43.3400022514 \cdot \left(x \cdot x\right) + x \cdot \left(x \cdot x\right)\right)\right) + 313.399215894\right) \cdot x + 47.066876606}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{y}{x \cdot x} + 4.16438922228 \cdot x\right) - 110.1139242984811\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -1.0082194143627248e+25 or 1.3289883024938852e+23 < x

    1. Initial program 55.1

      \[\frac{\left(x - 2.0\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606}\]
    2. Simplified51.1

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), y\right), z\right) \cdot \frac{x - 2.0}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}}\]
    3. Taylor expanded around inf 1.7

      \[\leadsto \color{blue}{\left(\frac{y}{{x}^{2}} + 4.16438922228 \cdot x\right) - 110.1139242984811}\]
    4. Simplified1.7

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 4.16438922228, \frac{y}{x \cdot x}\right) - 110.1139242984811}\]

    if -1.0082194143627248e+25 < x < 1.3289883024938852e+23

    1. Initial program 0.4

      \[\frac{\left(x - 2.0\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606}\]
    2. Simplified0.5

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), y\right), z\right) \cdot \frac{x - 2.0}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt0.8

      \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), y\right), z\right) \cdot \frac{x - 2.0}{\color{blue}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)} \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}}}\]
    5. Applied *-un-lft-identity0.8

      \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), y\right), z\right) \cdot \frac{\color{blue}{1 \cdot \left(x - 2.0\right)}}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)} \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}}\]
    6. Applied times-frac0.9

      \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), y\right), z\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}} \cdot \frac{x - 2.0}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}}\right)}\]
    7. Applied associate-*r*0.7

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), y\right), z\right) \cdot \frac{1}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}}\right) \cdot \frac{x - 2.0}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}}}\]
    8. Using strategy rm
    9. Applied pow10.7

      \[\leadsto \left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), y\right), z\right) \cdot \frac{1}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}}\right) \cdot \color{blue}{{\left(\frac{x - 2.0}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}}\right)}^{1}}\]
    10. Applied pow10.7

      \[\leadsto \left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), y\right), z\right) \cdot \color{blue}{{\left(\frac{1}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}}\right)}^{1}}\right) \cdot {\left(\frac{x - 2.0}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}}\right)}^{1}\]
    11. Applied pow10.7

      \[\leadsto \left(\color{blue}{{\left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), y\right), z\right)\right)}^{1}} \cdot {\left(\frac{1}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}}\right)}^{1}\right) \cdot {\left(\frac{x - 2.0}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}}\right)}^{1}\]
    12. Applied pow-prod-down0.7

      \[\leadsto \color{blue}{{\left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), y\right), z\right) \cdot \frac{1}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}}\right)}^{1}} \cdot {\left(\frac{x - 2.0}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}}\right)}^{1}\]
    13. Applied pow-prod-down0.7

      \[\leadsto \color{blue}{{\left(\left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922228, 78.6994924154\right), 137.519416416\right), y\right), z\right) \cdot \frac{1}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}}\right) \cdot \frac{x - 2.0}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}}\right)}^{1}}\]
    14. Simplified0.7

      \[\leadsto {\color{blue}{\left(\frac{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(4.16438922228, x, 78.6994924154\right), x, 137.519416416\right), y\right), z\right)}{\sqrt{\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), 47.066876606\right)}}}{\frac{\sqrt{\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), 47.066876606\right)}}{x - 2.0}}\right)}}^{1}\]
    15. Using strategy rm
    16. Applied associate-/r/0.7

      \[\leadsto {\color{blue}{\left(\frac{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(4.16438922228, x, 78.6994924154\right), x, 137.519416416\right), y\right), z\right)}{\sqrt{\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), 47.066876606\right)}}}{\sqrt{\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), 47.066876606\right)}} \cdot \left(x - 2.0\right)\right)}}^{1}\]
    17. Simplified0.2

      \[\leadsto {\left(\color{blue}{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(4.16438922228, x, 78.6994924154\right), x, 137.519416416\right), y\right), z\right)}{\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), 47.066876606\right)}} \cdot \left(x - 2.0\right)\right)}^{1}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.0082194143627248 \cdot 10^{+25}:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922228, \frac{y}{x \cdot x}\right) - 110.1139242984811\\ \mathbf{elif}\;x \le 1.3289883024938852 \cdot 10^{+23}:\\ \;\;\;\;\left(x - 2.0\right) \cdot \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(4.16438922228, x, 78.6994924154\right), x, 137.519416416\right), y\right), z\right)}{\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), 47.066876606\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922228, \frac{y}{x \cdot x}\right) - 110.1139242984811\\ \end{array}\]

Reproduce

herbie shell --seed 2019158 +o rules:numerics
(FPCore (x y z)
  :name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, C"

  :herbie-target
  (if (< x -3.326128725870005e+62) (- (+ (/ y (* x x)) (* 4.16438922228 x)) 110.1139242984811) (if (< x 9.429991714554673e+55) (* (/ (- x 2.0) 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.0) (+ (* (+ (* (+ (* (+ (* x 4.16438922228) 78.6994924154) x) 137.519416416) x) y) x) z)) (+ (* (+ (* (+ (* (+ x 43.3400022514) x) 263.505074721) x) 313.399215894) x) 47.066876606)))