Average Error: 26.8 → 0.6
Time: 10.5s
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.37322170457412272 \cdot 10^{60} \lor \neg \left(x \le 4.54262428893722098 \cdot 10^{64}\right):\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}}\right) - 110.11392429848109\\ \mathbf{else}:\\ \;\;\;\;\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 \frac{x - 2}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\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.37322170457412272 \cdot 10^{60} \lor \neg \left(x \le 4.54262428893722098 \cdot 10^{64}\right):\\
\;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}}\right) - 110.11392429848109\\

\mathbf{else}:\\
\;\;\;\;\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 \frac{x - 2}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}\\

\end{array}
double f(double x, double y, double z) {
        double r315134 = x;
        double r315135 = 2.0;
        double r315136 = r315134 - r315135;
        double r315137 = 4.16438922228;
        double r315138 = r315134 * r315137;
        double r315139 = 78.6994924154;
        double r315140 = r315138 + r315139;
        double r315141 = r315140 * r315134;
        double r315142 = 137.519416416;
        double r315143 = r315141 + r315142;
        double r315144 = r315143 * r315134;
        double r315145 = y;
        double r315146 = r315144 + r315145;
        double r315147 = r315146 * r315134;
        double r315148 = z;
        double r315149 = r315147 + r315148;
        double r315150 = r315136 * r315149;
        double r315151 = 43.3400022514;
        double r315152 = r315134 + r315151;
        double r315153 = r315152 * r315134;
        double r315154 = 263.505074721;
        double r315155 = r315153 + r315154;
        double r315156 = r315155 * r315134;
        double r315157 = 313.399215894;
        double r315158 = r315156 + r315157;
        double r315159 = r315158 * r315134;
        double r315160 = 47.066876606;
        double r315161 = r315159 + r315160;
        double r315162 = r315150 / r315161;
        return r315162;
}

double f(double x, double y, double z) {
        double r315163 = x;
        double r315164 = -4.373221704574123e+60;
        bool r315165 = r315163 <= r315164;
        double r315166 = 4.542624288937221e+64;
        bool r315167 = r315163 <= r315166;
        double r315168 = !r315167;
        bool r315169 = r315165 || r315168;
        double r315170 = 4.16438922228;
        double r315171 = y;
        double r315172 = 2.0;
        double r315173 = pow(r315163, r315172);
        double r315174 = r315171 / r315173;
        double r315175 = fma(r315163, r315170, r315174);
        double r315176 = 110.1139242984811;
        double r315177 = r315175 - r315176;
        double r315178 = 78.6994924154;
        double r315179 = fma(r315163, r315170, r315178);
        double r315180 = 137.519416416;
        double r315181 = fma(r315179, r315163, r315180);
        double r315182 = fma(r315181, r315163, r315171);
        double r315183 = z;
        double r315184 = fma(r315182, r315163, r315183);
        double r315185 = 2.0;
        double r315186 = r315163 - r315185;
        double r315187 = 43.3400022514;
        double r315188 = r315163 + r315187;
        double r315189 = 263.505074721;
        double r315190 = fma(r315188, r315163, r315189);
        double r315191 = 313.399215894;
        double r315192 = fma(r315190, r315163, r315191);
        double r315193 = 47.066876606;
        double r315194 = fma(r315192, r315163, r315193);
        double r315195 = r315186 / r315194;
        double r315196 = r315184 * r315195;
        double r315197 = r315169 ? r315177 : r315196;
        return r315197;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original26.8
Target0.4
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.373221704574123e+60 or 4.542624288937221e+64 < x

    1. Initial program 63.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. Simplified63.9

      \[\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 *-un-lft-identity63.9

      \[\leadsto \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)}{\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)}}\]
    5. Applied times-frac61.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)}{1} \cdot \frac{x - 2}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}\]
    6. Simplified61.0

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

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

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

    if -4.373221704574123e+60 < x < 4.542624288937221e+64

    1. Initial program 1.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. Simplified1.9

      \[\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 *-un-lft-identity1.9

      \[\leadsto \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)}{\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)}}\]
    5. Applied times-frac0.9

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

      \[\leadsto \color{blue}{\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 \frac{x - 2}{\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. Recombined 2 regimes into one program.
  4. Final simplification0.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -4.37322170457412272 \cdot 10^{60} \lor \neg \left(x \le 4.54262428893722098 \cdot 10^{64}\right):\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}}\right) - 110.11392429848109\\ \mathbf{else}:\\ \;\;\;\;\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 \frac{x - 2}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}\\ \end{array}\]

Reproduce

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