Average Error: 26.0 → 0.5
Time: 36.1s
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.247417882216234 \cdot 10^{+41}:\\ \;\;\;\;\mathsf{fma}\left(4.16438922228, x, \frac{y}{x \cdot x} - 110.1139242984811\right)\\ \mathbf{elif}\;x \le 3.1512810687298216 \cdot 10^{+66}:\\ \;\;\;\;\left(x - 2.0\right) \cdot \frac{\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)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(4.16438922228, x, \frac{y}{x \cdot x} - 110.1139242984811\right)\\ \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.247417882216234 \cdot 10^{+41}:\\
\;\;\;\;\mathsf{fma}\left(4.16438922228, x, \frac{y}{x \cdot x} - 110.1139242984811\right)\\

\mathbf{elif}\;x \le 3.1512810687298216 \cdot 10^{+66}:\\
\;\;\;\;\left(x - 2.0\right) \cdot \frac{\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)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}\\

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

\end{array}
double f(double x, double y, double z) {
        double r14329125 = x;
        double r14329126 = 2.0;
        double r14329127 = r14329125 - r14329126;
        double r14329128 = 4.16438922228;
        double r14329129 = r14329125 * r14329128;
        double r14329130 = 78.6994924154;
        double r14329131 = r14329129 + r14329130;
        double r14329132 = r14329131 * r14329125;
        double r14329133 = 137.519416416;
        double r14329134 = r14329132 + r14329133;
        double r14329135 = r14329134 * r14329125;
        double r14329136 = y;
        double r14329137 = r14329135 + r14329136;
        double r14329138 = r14329137 * r14329125;
        double r14329139 = z;
        double r14329140 = r14329138 + r14329139;
        double r14329141 = r14329127 * r14329140;
        double r14329142 = 43.3400022514;
        double r14329143 = r14329125 + r14329142;
        double r14329144 = r14329143 * r14329125;
        double r14329145 = 263.505074721;
        double r14329146 = r14329144 + r14329145;
        double r14329147 = r14329146 * r14329125;
        double r14329148 = 313.399215894;
        double r14329149 = r14329147 + r14329148;
        double r14329150 = r14329149 * r14329125;
        double r14329151 = 47.066876606;
        double r14329152 = r14329150 + r14329151;
        double r14329153 = r14329141 / r14329152;
        return r14329153;
}

double f(double x, double y, double z) {
        double r14329154 = x;
        double r14329155 = -1.247417882216234e+41;
        bool r14329156 = r14329154 <= r14329155;
        double r14329157 = 4.16438922228;
        double r14329158 = y;
        double r14329159 = r14329154 * r14329154;
        double r14329160 = r14329158 / r14329159;
        double r14329161 = 110.1139242984811;
        double r14329162 = r14329160 - r14329161;
        double r14329163 = fma(r14329157, r14329154, r14329162);
        double r14329164 = 3.1512810687298216e+66;
        bool r14329165 = r14329154 <= r14329164;
        double r14329166 = 2.0;
        double r14329167 = r14329154 - r14329166;
        double r14329168 = 78.6994924154;
        double r14329169 = fma(r14329154, r14329157, r14329168);
        double r14329170 = 137.519416416;
        double r14329171 = fma(r14329154, r14329169, r14329170);
        double r14329172 = fma(r14329154, r14329171, r14329158);
        double r14329173 = z;
        double r14329174 = fma(r14329154, r14329172, r14329173);
        double r14329175 = 43.3400022514;
        double r14329176 = r14329154 + r14329175;
        double r14329177 = 263.505074721;
        double r14329178 = fma(r14329176, r14329154, r14329177);
        double r14329179 = 313.399215894;
        double r14329180 = fma(r14329178, r14329154, r14329179);
        double r14329181 = 47.066876606;
        double r14329182 = fma(r14329180, r14329154, r14329181);
        double r14329183 = r14329174 / r14329182;
        double r14329184 = r14329167 * r14329183;
        double r14329185 = r14329165 ? r14329184 : r14329163;
        double r14329186 = r14329156 ? r14329163 : r14329185;
        return r14329186;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original26.0
Target0.5
Herbie0.5
\[\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.247417882216234e+41 or 3.1512810687298216e+66 < x

    1. Initial program 60.2

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

      \[\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 div-sub57.0

      \[\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{x}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)} - \frac{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)}\right)}\]
    5. Using strategy rm
    6. Applied div-inv57.0

      \[\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 \left(\frac{x}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)} - \color{blue}{2.0 \cdot \frac{1}{\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 div-inv57.0

      \[\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 \left(\color{blue}{x \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}} - 2.0 \cdot \frac{1}{\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)\]
    8. Applied distribute-rgt-out--57.0

      \[\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}{\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 \left(x - 2.0\right)\right)}\]
    9. Applied associate-*r*57.0

      \[\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}{\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 \left(x - 2.0\right)}\]
    10. Simplified57.0

      \[\leadsto \color{blue}{\frac{\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)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}} \cdot \left(x - 2.0\right)\]
    11. Taylor expanded around inf 0.5

      \[\leadsto \color{blue}{\left(\frac{y}{{x}^{2}} + 4.16438922228 \cdot x\right) - 110.1139242984811}\]
    12. Simplified0.5

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

    if -1.247417882216234e+41 < x < 3.1512810687298216e+66

    1. Initial program 1.6

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

      \[\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 div-sub0.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 \color{blue}{\left(\frac{x}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)} - \frac{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)}\right)}\]
    5. Using strategy rm
    6. Applied div-inv0.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 \left(\frac{x}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)} - \color{blue}{2.0 \cdot \frac{1}{\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 div-inv0.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 \left(\color{blue}{x \cdot \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514 + x, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}} - 2.0 \cdot \frac{1}{\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)\]
    8. Applied distribute-rgt-out--0.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 \color{blue}{\left(\frac{1}{\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 \left(x - 2.0\right)\right)}\]
    9. Applied associate-*r*0.8

      \[\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}{\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 \left(x - 2.0\right)}\]
    10. Simplified0.5

      \[\leadsto \color{blue}{\frac{\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)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}} \cdot \left(x - 2.0\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.247417882216234 \cdot 10^{+41}:\\ \;\;\;\;\mathsf{fma}\left(4.16438922228, x, \frac{y}{x \cdot x} - 110.1139242984811\right)\\ \mathbf{elif}\;x \le 3.1512810687298216 \cdot 10^{+66}:\\ \;\;\;\;\left(x - 2.0\right) \cdot \frac{\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)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514, x, 263.505074721\right), x, 313.399215894\right), x, 47.066876606\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(4.16438922228, x, \frac{y}{x \cdot x} - 110.1139242984811\right)\\ \end{array}\]

Reproduce

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