Average Error: 26.1 → 0.9
Time: 21.0s
Precision: 64
\[\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999963610045597306452691555 + 78.69949241540000173245061887428164482117\right) \cdot x + 137.5194164160000127594685181975364685059\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000013984514225739985704422\right) \cdot x + 263.5050747210000281484099105000495910645\right) \cdot x + 313.3992158940000081202015280723571777344\right) \cdot x + 47.06687660600000100430406746454536914825}\]
\[\begin{array}{l} \mathbf{if}\;x \le -288151121519641987601399808 \lor \neg \left(x \le 14456844266184348924014231552\right):\\ \;\;\;\;\mathsf{fma}\left(4.16438922227999963610045597306452691555, x, \frac{y}{{x}^{2}}\right) - 110.1139242984810806547102401964366436005\\ \mathbf{else}:\\ \;\;\;\;\frac{\left({x}^{3} - {2}^{3}\right) \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}}{x \cdot x + \left(2 \cdot 2 + x \cdot 2\right)}\\ \end{array}\]
\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999963610045597306452691555 + 78.69949241540000173245061887428164482117\right) \cdot x + 137.5194164160000127594685181975364685059\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000013984514225739985704422\right) \cdot x + 263.5050747210000281484099105000495910645\right) \cdot x + 313.3992158940000081202015280723571777344\right) \cdot x + 47.06687660600000100430406746454536914825}
\begin{array}{l}
\mathbf{if}\;x \le -288151121519641987601399808 \lor \neg \left(x \le 14456844266184348924014231552\right):\\
\;\;\;\;\mathsf{fma}\left(4.16438922227999963610045597306452691555, x, \frac{y}{{x}^{2}}\right) - 110.1139242984810806547102401964366436005\\

\mathbf{else}:\\
\;\;\;\;\frac{\left({x}^{3} - {2}^{3}\right) \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}}{x \cdot x + \left(2 \cdot 2 + x \cdot 2\right)}\\

\end{array}
double f(double x, double y, double z) {
        double r256963 = x;
        double r256964 = 2.0;
        double r256965 = r256963 - r256964;
        double r256966 = 4.16438922228;
        double r256967 = r256963 * r256966;
        double r256968 = 78.6994924154;
        double r256969 = r256967 + r256968;
        double r256970 = r256969 * r256963;
        double r256971 = 137.519416416;
        double r256972 = r256970 + r256971;
        double r256973 = r256972 * r256963;
        double r256974 = y;
        double r256975 = r256973 + r256974;
        double r256976 = r256975 * r256963;
        double r256977 = z;
        double r256978 = r256976 + r256977;
        double r256979 = r256965 * r256978;
        double r256980 = 43.3400022514;
        double r256981 = r256963 + r256980;
        double r256982 = r256981 * r256963;
        double r256983 = 263.505074721;
        double r256984 = r256982 + r256983;
        double r256985 = r256984 * r256963;
        double r256986 = 313.399215894;
        double r256987 = r256985 + r256986;
        double r256988 = r256987 * r256963;
        double r256989 = 47.066876606;
        double r256990 = r256988 + r256989;
        double r256991 = r256979 / r256990;
        return r256991;
}

double f(double x, double y, double z) {
        double r256992 = x;
        double r256993 = -2.88151121519642e+26;
        bool r256994 = r256992 <= r256993;
        double r256995 = 1.445684426618435e+28;
        bool r256996 = r256992 <= r256995;
        double r256997 = !r256996;
        bool r256998 = r256994 || r256997;
        double r256999 = 4.16438922228;
        double r257000 = y;
        double r257001 = 2.0;
        double r257002 = pow(r256992, r257001);
        double r257003 = r257000 / r257002;
        double r257004 = fma(r256999, r256992, r257003);
        double r257005 = 110.11392429848108;
        double r257006 = r257004 - r257005;
        double r257007 = 3.0;
        double r257008 = pow(r256992, r257007);
        double r257009 = 2.0;
        double r257010 = pow(r257009, r257007);
        double r257011 = r257008 - r257010;
        double r257012 = 78.6994924154;
        double r257013 = fma(r256992, r256999, r257012);
        double r257014 = 137.519416416;
        double r257015 = fma(r257013, r256992, r257014);
        double r257016 = fma(r257015, r256992, r257000);
        double r257017 = z;
        double r257018 = fma(r257016, r256992, r257017);
        double r257019 = 43.3400022514;
        double r257020 = r256992 + r257019;
        double r257021 = 263.505074721;
        double r257022 = fma(r257020, r256992, r257021);
        double r257023 = 313.399215894;
        double r257024 = fma(r257022, r256992, r257023);
        double r257025 = 47.066876606;
        double r257026 = fma(r257024, r256992, r257025);
        double r257027 = r257018 / r257026;
        double r257028 = r257011 * r257027;
        double r257029 = r256992 * r256992;
        double r257030 = r257009 * r257009;
        double r257031 = r256992 * r257009;
        double r257032 = r257030 + r257031;
        double r257033 = r257029 + r257032;
        double r257034 = r257028 / r257033;
        double r257035 = r256998 ? r257006 : r257034;
        return r257035;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original26.1
Target0.6
Herbie0.9
\[\begin{array}{l} \mathbf{if}\;x \lt -3.326128725870004842699683658678411714981 \cdot 10^{62}:\\ \;\;\;\;\left(\frac{y}{x \cdot x} + 4.16438922227999963610045597306452691555 \cdot x\right) - 110.1139242984810948655649553984403610229\\ \mathbf{elif}\;x \lt 9.429991714554672672712552870340896976735 \cdot 10^{55}:\\ \;\;\;\;\frac{x - 2}{1} \cdot \frac{\left(\left(\left(x \cdot 4.16438922227999963610045597306452691555 + 78.69949241540000173245061887428164482117\right) \cdot x + 137.5194164160000127594685181975364685059\right) \cdot x + y\right) \cdot x + z}{\left(\left(263.5050747210000281484099105000495910645 \cdot x + \left(43.3400022514000013984514225739985704422 \cdot \left(x \cdot x\right) + x \cdot \left(x \cdot x\right)\right)\right) + 313.3992158940000081202015280723571777344\right) \cdot x + 47.06687660600000100430406746454536914825}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{y}{x \cdot x} + 4.16438922227999963610045597306452691555 \cdot x\right) - 110.1139242984810948655649553984403610229\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -2.88151121519642e+26 or 1.445684426618435e+28 < x

    1. Initial program 57.8

      \[\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999963610045597306452691555 + 78.69949241540000173245061887428164482117\right) \cdot x + 137.5194164160000127594685181975364685059\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000013984514225739985704422\right) \cdot x + 263.5050747210000281484099105000495910645\right) \cdot x + 313.3992158940000081202015280723571777344\right) \cdot x + 47.06687660600000100430406746454536914825}\]
    2. Simplified53.6

      \[\leadsto \color{blue}{\frac{x - 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}}}\]
    3. Using strategy rm
    4. Applied div-inv53.6

      \[\leadsto \color{blue}{\left(x - 2\right) \cdot \frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}}}\]
    5. Simplified53.6

      \[\leadsto \left(x - 2\right) \cdot \color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}}\]
    6. Using strategy rm
    7. Applied flip3--53.7

      \[\leadsto \color{blue}{\frac{{x}^{3} - {2}^{3}}{x \cdot x + \left(2 \cdot 2 + x \cdot 2\right)}} \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}\]
    8. Applied associate-*l/53.7

      \[\leadsto \color{blue}{\frac{\left({x}^{3} - {2}^{3}\right) \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}}{x \cdot x + \left(2 \cdot 2 + x \cdot 2\right)}}\]
    9. Taylor expanded around inf 1.5

      \[\leadsto \color{blue}{\left(\frac{y}{{x}^{2}} + 4.16438922227999963610045597306452691555 \cdot x\right) - 110.1139242984810806547102401964366436005}\]
    10. Simplified1.5

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

    if -2.88151121519642e+26 < x < 1.445684426618435e+28

    1. Initial program 0.7

      \[\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999963610045597306452691555 + 78.69949241540000173245061887428164482117\right) \cdot x + 137.5194164160000127594685181975364685059\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000013984514225739985704422\right) \cdot x + 263.5050747210000281484099105000495910645\right) \cdot x + 313.3992158940000081202015280723571777344\right) \cdot x + 47.06687660600000100430406746454536914825}\]
    2. Simplified0.5

      \[\leadsto \color{blue}{\frac{x - 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}}}\]
    3. Using strategy rm
    4. Applied div-inv0.5

      \[\leadsto \color{blue}{\left(x - 2\right) \cdot \frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}}}\]
    5. Simplified0.3

      \[\leadsto \left(x - 2\right) \cdot \color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}}\]
    6. Using strategy rm
    7. Applied flip3--0.3

      \[\leadsto \color{blue}{\frac{{x}^{3} - {2}^{3}}{x \cdot x + \left(2 \cdot 2 + x \cdot 2\right)}} \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}\]
    8. Applied associate-*l/0.3

      \[\leadsto \color{blue}{\frac{\left({x}^{3} - {2}^{3}\right) \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}}{x \cdot x + \left(2 \cdot 2 + x \cdot 2\right)}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -288151121519641987601399808 \lor \neg \left(x \le 14456844266184348924014231552\right):\\ \;\;\;\;\mathsf{fma}\left(4.16438922227999963610045597306452691555, x, \frac{y}{{x}^{2}}\right) - 110.1139242984810806547102401964366436005\\ \mathbf{else}:\\ \;\;\;\;\frac{\left({x}^{3} - {2}^{3}\right) \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), x, 137.5194164160000127594685181975364685059\right), x, y\right), x, z\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}}{x \cdot x + \left(2 \cdot 2 + x \cdot 2\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2019303 +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.3261287258700048e62) (- (+ (/ y (* x x)) (* 4.16438922227999964 x)) 110.11392429848109) (if (< x 9.4299917145546727e55) (* (/ (- x 2) 1) (/ (+ (* (+ (* (+ (* (+ (* x 4.16438922227999964) 78.6994924154000017) x) 137.51941641600001) x) y) x) z) (+ (* (+ (+ (* 263.50507472100003 x) (+ (* 43.3400022514000014 (* x x)) (* x (* x x)))) 313.399215894) x) 47.066876606000001))) (- (+ (/ y (* x x)) (* 4.16438922227999964 x)) 110.11392429848109)))

  (/ (* (- x 2) (+ (* (+ (* (+ (* (+ (* x 4.16438922227999964) 78.6994924154000017) x) 137.51941641600001) x) y) x) z)) (+ (* (+ (* (+ (* (+ x 43.3400022514000014) x) 263.50507472100003) x) 313.399215894) x) 47.066876606000001)))