Average Error: 27.5 → 0.5
Time: 12.6s
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 -3.2249422671409879 \cdot 10^{47} \lor \neg \left(x \le 3.6379943132031436 \cdot 10^{44}\right):\\ \;\;\;\;\mathsf{fma}\left(4.16438922227999964, x, \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)}{\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 - 2\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 -3.2249422671409879 \cdot 10^{47} \lor \neg \left(x \le 3.6379943132031436 \cdot 10^{44}\right):\\
\;\;\;\;\mathsf{fma}\left(4.16438922227999964, x, \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)}{\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 - 2\right)\\

\end{array}
double f(double x, double y, double z) {
        double r442196 = x;
        double r442197 = 2.0;
        double r442198 = r442196 - r442197;
        double r442199 = 4.16438922228;
        double r442200 = r442196 * r442199;
        double r442201 = 78.6994924154;
        double r442202 = r442200 + r442201;
        double r442203 = r442202 * r442196;
        double r442204 = 137.519416416;
        double r442205 = r442203 + r442204;
        double r442206 = r442205 * r442196;
        double r442207 = y;
        double r442208 = r442206 + r442207;
        double r442209 = r442208 * r442196;
        double r442210 = z;
        double r442211 = r442209 + r442210;
        double r442212 = r442198 * r442211;
        double r442213 = 43.3400022514;
        double r442214 = r442196 + r442213;
        double r442215 = r442214 * r442196;
        double r442216 = 263.505074721;
        double r442217 = r442215 + r442216;
        double r442218 = r442217 * r442196;
        double r442219 = 313.399215894;
        double r442220 = r442218 + r442219;
        double r442221 = r442220 * r442196;
        double r442222 = 47.066876606;
        double r442223 = r442221 + r442222;
        double r442224 = r442212 / r442223;
        return r442224;
}

double f(double x, double y, double z) {
        double r442225 = x;
        double r442226 = -3.224942267140988e+47;
        bool r442227 = r442225 <= r442226;
        double r442228 = 3.6379943132031436e+44;
        bool r442229 = r442225 <= r442228;
        double r442230 = !r442229;
        bool r442231 = r442227 || r442230;
        double r442232 = 4.16438922228;
        double r442233 = y;
        double r442234 = 2.0;
        double r442235 = pow(r442225, r442234);
        double r442236 = r442233 / r442235;
        double r442237 = fma(r442232, r442225, r442236);
        double r442238 = 110.1139242984811;
        double r442239 = r442237 - r442238;
        double r442240 = 78.6994924154;
        double r442241 = fma(r442225, r442232, r442240);
        double r442242 = 137.519416416;
        double r442243 = fma(r442241, r442225, r442242);
        double r442244 = fma(r442243, r442225, r442233);
        double r442245 = z;
        double r442246 = fma(r442244, r442225, r442245);
        double r442247 = 43.3400022514;
        double r442248 = r442225 + r442247;
        double r442249 = 263.505074721;
        double r442250 = fma(r442248, r442225, r442249);
        double r442251 = 313.399215894;
        double r442252 = fma(r442250, r442225, r442251);
        double r442253 = 47.066876606;
        double r442254 = fma(r442252, r442225, r442253);
        double r442255 = r442246 / r442254;
        double r442256 = 2.0;
        double r442257 = r442225 - r442256;
        double r442258 = r442255 * r442257;
        double r442259 = r442231 ? r442239 : r442258;
        return r442259;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original27.5
Target0.5
Herbie0.5
\[\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 < -3.224942267140988e+47 or 3.6379943132031436e+44 < x

    1. Initial program 61.5

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

      \[\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 associate-/l*58.0

      \[\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)}{\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)}{x - 2}}}\]
    5. Using strategy rm
    6. Applied clear-num58.1

      \[\leadsto \color{blue}{\frac{1}{\frac{\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)}{x - 2}}{\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. Taylor expanded around inf 0.5

      \[\leadsto \color{blue}{\left(\frac{y}{{x}^{2}} + 4.16438922227999964 \cdot x\right) - 110.11392429848109}\]
    8. Simplified0.5

      \[\leadsto \color{blue}{\mathsf{fma}\left(4.16438922227999964, x, \frac{y}{{x}^{2}}\right) - 110.11392429848109}\]

    if -3.224942267140988e+47 < x < 3.6379943132031436e+44

    1. Initial program 1.2

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

      \[\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 associate-/l*0.4

      \[\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)}{\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)}{x - 2}}}\]
    5. Using strategy rm
    6. Applied associate-/r/0.4

      \[\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)}{\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 - 2\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -3.2249422671409879 \cdot 10^{47} \lor \neg \left(x \le 3.6379943132031436 \cdot 10^{44}\right):\\ \;\;\;\;\mathsf{fma}\left(4.16438922227999964, x, \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)}{\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 - 2\right)\\ \end{array}\]

Reproduce

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