Average Error: 26.8 → 0.8
Time: 8.8s
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 -1.2270580557324376 \cdot 10^{54} \lor \neg \left(x \le 1.17686368158435667 \cdot 10^{46}\right):\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}} - 110.11392429848109\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot x - 2 \cdot 2}{\frac{\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)}}{\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)}}} \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 -1.2270580557324376 \cdot 10^{54} \lor \neg \left(x \le 1.17686368158435667 \cdot 10^{46}\right):\\
\;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}} - 110.11392429848109\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r347058 = x;
        double r347059 = 2.0;
        double r347060 = r347058 - r347059;
        double r347061 = 4.16438922228;
        double r347062 = r347058 * r347061;
        double r347063 = 78.6994924154;
        double r347064 = r347062 + r347063;
        double r347065 = r347064 * r347058;
        double r347066 = 137.519416416;
        double r347067 = r347065 + r347066;
        double r347068 = r347067 * r347058;
        double r347069 = y;
        double r347070 = r347068 + r347069;
        double r347071 = r347070 * r347058;
        double r347072 = z;
        double r347073 = r347071 + r347072;
        double r347074 = r347060 * r347073;
        double r347075 = 43.3400022514;
        double r347076 = r347058 + r347075;
        double r347077 = r347076 * r347058;
        double r347078 = 263.505074721;
        double r347079 = r347077 + r347078;
        double r347080 = r347079 * r347058;
        double r347081 = 313.399215894;
        double r347082 = r347080 + r347081;
        double r347083 = r347082 * r347058;
        double r347084 = 47.066876606;
        double r347085 = r347083 + r347084;
        double r347086 = r347074 / r347085;
        return r347086;
}

double f(double x, double y, double z) {
        double r347087 = x;
        double r347088 = -1.2270580557324376e+54;
        bool r347089 = r347087 <= r347088;
        double r347090 = 1.1768636815843567e+46;
        bool r347091 = r347087 <= r347090;
        double r347092 = !r347091;
        bool r347093 = r347089 || r347092;
        double r347094 = 4.16438922228;
        double r347095 = y;
        double r347096 = 2.0;
        double r347097 = pow(r347087, r347096);
        double r347098 = r347095 / r347097;
        double r347099 = 110.1139242984811;
        double r347100 = r347098 - r347099;
        double r347101 = fma(r347087, r347094, r347100);
        double r347102 = r347087 * r347087;
        double r347103 = 2.0;
        double r347104 = r347103 * r347103;
        double r347105 = r347102 - r347104;
        double r347106 = 43.3400022514;
        double r347107 = r347087 + r347106;
        double r347108 = 263.505074721;
        double r347109 = fma(r347107, r347087, r347108);
        double r347110 = 313.399215894;
        double r347111 = fma(r347109, r347087, r347110);
        double r347112 = 47.066876606;
        double r347113 = fma(r347111, r347087, r347112);
        double r347114 = sqrt(r347113);
        double r347115 = 78.6994924154;
        double r347116 = fma(r347087, r347094, r347115);
        double r347117 = 137.519416416;
        double r347118 = fma(r347116, r347087, r347117);
        double r347119 = fma(r347118, r347087, r347095);
        double r347120 = z;
        double r347121 = fma(r347119, r347087, r347120);
        double r347122 = r347121 / r347114;
        double r347123 = r347114 / r347122;
        double r347124 = r347087 + r347103;
        double r347125 = r347123 * r347124;
        double r347126 = r347105 / r347125;
        double r347127 = r347093 ? r347101 : r347126;
        return r347127;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original26.8
Target0.6
Herbie0.8
\[\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 < -1.2270580557324376e+54 or 1.1768636815843567e+46 < x

    1. Initial program 61.8

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

      \[\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. Taylor expanded around inf 0.5

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

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

    if -1.2270580557324376e+54 < x < 1.1768636815843567e+46

    1. Initial program 1.3

      \[\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 flip--0.8

      \[\leadsto \frac{\color{blue}{\frac{x \cdot x - 2 \cdot 2}{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)}}\]
    5. Applied associate-/l/0.8

      \[\leadsto \color{blue}{\frac{x \cdot x - 2 \cdot 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)} \cdot \left(x + 2\right)}}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt1.0

      \[\leadsto \frac{x \cdot x - 2 \cdot 2}{\frac{\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)}}}{\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)}\]
    8. Applied associate-/l*1.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.2270580557324376 \cdot 10^{54} \lor \neg \left(x \le 1.17686368158435667 \cdot 10^{46}\right):\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}} - 110.11392429848109\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot x - 2 \cdot 2}{\frac{\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)}}{\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)}}} \cdot \left(x + 2\right)}\\ \end{array}\]

Reproduce

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