Average Error: 26.9 → 1.3
Time: 35.5s
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 -61687932491585565641087647744 \lor \neg \left(x \le 620615997107907.625\right):\\ \;\;\;\;\mathsf{fma}\left(4.16438922227999963610045597306452691555, x, \frac{y}{x \cdot x} - 110.1139242984810948655649553984403610229\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(4.16438922227999963610045597306452691555, x, 78.69949241540000173245061887428164482117\right), 137.5194164160000127594685181975364685059\right), y\right), z\right) \cdot \mathsf{fma}\left(-2, 2, x \cdot x\right)}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 43.3400022514000013984514225739985704422 + x, 263.5050747210000281484099105000495910645\right), 313.3992158940000081202015280723571777344\right), 47.06687660600000100430406746454536914825\right)}}{x + 2}\\ \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 -61687932491585565641087647744 \lor \neg \left(x \le 620615997107907.625\right):\\
\;\;\;\;\mathsf{fma}\left(4.16438922227999963610045597306452691555, x, \frac{y}{x \cdot x} - 110.1139242984810948655649553984403610229\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r301766 = x;
        double r301767 = 2.0;
        double r301768 = r301766 - r301767;
        double r301769 = 4.16438922228;
        double r301770 = r301766 * r301769;
        double r301771 = 78.6994924154;
        double r301772 = r301770 + r301771;
        double r301773 = r301772 * r301766;
        double r301774 = 137.519416416;
        double r301775 = r301773 + r301774;
        double r301776 = r301775 * r301766;
        double r301777 = y;
        double r301778 = r301776 + r301777;
        double r301779 = r301778 * r301766;
        double r301780 = z;
        double r301781 = r301779 + r301780;
        double r301782 = r301768 * r301781;
        double r301783 = 43.3400022514;
        double r301784 = r301766 + r301783;
        double r301785 = r301784 * r301766;
        double r301786 = 263.505074721;
        double r301787 = r301785 + r301786;
        double r301788 = r301787 * r301766;
        double r301789 = 313.399215894;
        double r301790 = r301788 + r301789;
        double r301791 = r301790 * r301766;
        double r301792 = 47.066876606;
        double r301793 = r301791 + r301792;
        double r301794 = r301782 / r301793;
        return r301794;
}

double f(double x, double y, double z) {
        double r301795 = x;
        double r301796 = -6.168793249158557e+28;
        bool r301797 = r301795 <= r301796;
        double r301798 = 620615997107907.6;
        bool r301799 = r301795 <= r301798;
        double r301800 = !r301799;
        bool r301801 = r301797 || r301800;
        double r301802 = 4.16438922228;
        double r301803 = y;
        double r301804 = r301795 * r301795;
        double r301805 = r301803 / r301804;
        double r301806 = 110.1139242984811;
        double r301807 = r301805 - r301806;
        double r301808 = fma(r301802, r301795, r301807);
        double r301809 = 78.6994924154;
        double r301810 = fma(r301802, r301795, r301809);
        double r301811 = 137.519416416;
        double r301812 = fma(r301795, r301810, r301811);
        double r301813 = fma(r301795, r301812, r301803);
        double r301814 = z;
        double r301815 = fma(r301795, r301813, r301814);
        double r301816 = 2.0;
        double r301817 = -r301816;
        double r301818 = fma(r301817, r301816, r301804);
        double r301819 = r301815 * r301818;
        double r301820 = 43.3400022514;
        double r301821 = r301820 + r301795;
        double r301822 = 263.505074721;
        double r301823 = fma(r301795, r301821, r301822);
        double r301824 = 313.399215894;
        double r301825 = fma(r301795, r301823, r301824);
        double r301826 = 47.066876606;
        double r301827 = fma(r301795, r301825, r301826);
        double r301828 = r301819 / r301827;
        double r301829 = r301795 + r301816;
        double r301830 = r301828 / r301829;
        double r301831 = r301801 ? r301808 : r301830;
        return r301831;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original26.9
Target0.6
Herbie1.3
\[\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 < -6.168793249158557e+28 or 620615997107907.6 < x

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\frac{y}{{x}^{2}} + 4.16438922227999963610045597306452691555 \cdot x\right) - 110.1139242984810948655649553984403610229}\]
    8. Simplified2.1

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

    if -6.168793249158557e+28 < x < 620615997107907.6

    1. Initial program 0.5

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

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

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

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

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

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

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

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

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

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

Reproduce

herbie shell --seed 2019174 +o rules:numerics
(FPCore (x y z)
  :name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, C"

  :herbie-target
  (if (< x -3.326128725870005e+62) (- (+ (/ y (* x x)) (* 4.16438922228 x)) 110.1139242984811) (if (< x 9.429991714554673e+55) (* (/ (- x 2.0) 1.0) (/ (+ (* (+ (* (+ (* (+ (* 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.0) (+ (* (+ (* (+ (* (+ (* x 4.16438922228) 78.6994924154) x) 137.519416416) x) y) x) z)) (+ (* (+ (* (+ (* (+ x 43.3400022514) x) 263.505074721) x) 313.399215894) x) 47.066876606)))