Average Error: 26.5 → 0.9
Time: 11.1s
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.3588681134848813 \cdot 10^{42} \lor \neg \left(x \le 1.38820808193331251 \cdot 10^{24}\right):\\ \;\;\;\;\left(\frac{y}{{x}^{2}} + 4.16438922227999964 \cdot x\right) - 110.11392429848109\\ \mathbf{else}:\\ \;\;\;\;\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}\\ \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.3588681134848813 \cdot 10^{42} \lor \neg \left(x \le 1.38820808193331251 \cdot 10^{24}\right):\\
\;\;\;\;\left(\frac{y}{{x}^{2}} + 4.16438922227999964 \cdot x\right) - 110.11392429848109\\

\mathbf{else}:\\
\;\;\;\;\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}\\

\end{array}
double f(double x, double y, double z) {
        double r368937 = x;
        double r368938 = 2.0;
        double r368939 = r368937 - r368938;
        double r368940 = 4.16438922228;
        double r368941 = r368937 * r368940;
        double r368942 = 78.6994924154;
        double r368943 = r368941 + r368942;
        double r368944 = r368943 * r368937;
        double r368945 = 137.519416416;
        double r368946 = r368944 + r368945;
        double r368947 = r368946 * r368937;
        double r368948 = y;
        double r368949 = r368947 + r368948;
        double r368950 = r368949 * r368937;
        double r368951 = z;
        double r368952 = r368950 + r368951;
        double r368953 = r368939 * r368952;
        double r368954 = 43.3400022514;
        double r368955 = r368937 + r368954;
        double r368956 = r368955 * r368937;
        double r368957 = 263.505074721;
        double r368958 = r368956 + r368957;
        double r368959 = r368958 * r368937;
        double r368960 = 313.399215894;
        double r368961 = r368959 + r368960;
        double r368962 = r368961 * r368937;
        double r368963 = 47.066876606;
        double r368964 = r368962 + r368963;
        double r368965 = r368953 / r368964;
        return r368965;
}

double f(double x, double y, double z) {
        double r368966 = x;
        double r368967 = -1.3588681134848813e+42;
        bool r368968 = r368966 <= r368967;
        double r368969 = 1.3882080819333125e+24;
        bool r368970 = r368966 <= r368969;
        double r368971 = !r368970;
        bool r368972 = r368968 || r368971;
        double r368973 = y;
        double r368974 = 2.0;
        double r368975 = pow(r368966, r368974);
        double r368976 = r368973 / r368975;
        double r368977 = 4.16438922228;
        double r368978 = r368977 * r368966;
        double r368979 = r368976 + r368978;
        double r368980 = 110.1139242984811;
        double r368981 = r368979 - r368980;
        double r368982 = 2.0;
        double r368983 = r368966 - r368982;
        double r368984 = r368966 * r368977;
        double r368985 = 78.6994924154;
        double r368986 = r368984 + r368985;
        double r368987 = r368986 * r368966;
        double r368988 = 137.519416416;
        double r368989 = r368987 + r368988;
        double r368990 = r368989 * r368966;
        double r368991 = r368990 + r368973;
        double r368992 = r368991 * r368966;
        double r368993 = z;
        double r368994 = r368992 + r368993;
        double r368995 = r368983 * r368994;
        double r368996 = 43.3400022514;
        double r368997 = r368966 + r368996;
        double r368998 = r368997 * r368966;
        double r368999 = 263.505074721;
        double r369000 = r368998 + r368999;
        double r369001 = r369000 * r368966;
        double r369002 = 313.399215894;
        double r369003 = r369001 + r369002;
        double r369004 = r369003 * r368966;
        double r369005 = 47.066876606;
        double r369006 = r369004 + r369005;
        double r369007 = r368995 / r369006;
        double r369008 = r368972 ? r368981 : r369007;
        return r369008;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original26.5
Target0.5
Herbie0.9
\[\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.3588681134848813e+42 or 1.3882080819333125e+24 < x

    1. Initial program 59.0

      \[\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. Simplified54.9

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

      \[\leadsto \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)}{\color{blue}{1 \cdot \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 add-sqr-sqrt54.9

      \[\leadsto \frac{x - 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)}}}{1 \cdot \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)}}\]
    6. Applied times-frac54.9

      \[\leadsto \frac{x - 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)}}{1} \cdot \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)}}{\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. Applied *-un-lft-identity54.9

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x - 2\right)}}{\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)}}{1} \cdot \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)}}{\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)}}\]
    8. Applied times-frac54.9

      \[\leadsto \color{blue}{\frac{1}{\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)}}{1}} \cdot \frac{x - 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)}}{\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)}}}\]
    9. Simplified54.9

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

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

    if -1.3588681134848813e+42 < x < 1.3882080819333125e+24

    1. Initial program 0.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.3588681134848813 \cdot 10^{42} \lor \neg \left(x \le 1.38820808193331251 \cdot 10^{24}\right):\\ \;\;\;\;\left(\frac{y}{{x}^{2}} + 4.16438922227999964 \cdot x\right) - 110.11392429848109\\ \mathbf{else}:\\ \;\;\;\;\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}\\ \end{array}\]

Reproduce

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