Average Error: 26.7 → 0.8
Time: 21.7s
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 -394748133220946787888436044907157651456:\\ \;\;\;\;\left(x - 2\right) \cdot \left(\left(\frac{y}{{x}^{3}} + 4.16438922227999963610045597306452691555\right) - \frac{101.785145853921093817007204052060842514}{x}\right)\\ \mathbf{elif}\;x \le 998303336278827940708352:\\ \;\;\;\;\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)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(4.16438922227999963610045597306452691555, x, \frac{y}{{x}^{2}}\right) - 110.1139242984810948655649553984403610229\\ \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 -394748133220946787888436044907157651456:\\
\;\;\;\;\left(x - 2\right) \cdot \left(\left(\frac{y}{{x}^{3}} + 4.16438922227999963610045597306452691555\right) - \frac{101.785145853921093817007204052060842514}{x}\right)\\

\mathbf{elif}\;x \le 998303336278827940708352:\\
\;\;\;\;\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)}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(4.16438922227999963610045597306452691555, x, \frac{y}{{x}^{2}}\right) - 110.1139242984810948655649553984403610229\\

\end{array}
double f(double x, double y, double z) {
        double r233741 = x;
        double r233742 = 2.0;
        double r233743 = r233741 - r233742;
        double r233744 = 4.16438922228;
        double r233745 = r233741 * r233744;
        double r233746 = 78.6994924154;
        double r233747 = r233745 + r233746;
        double r233748 = r233747 * r233741;
        double r233749 = 137.519416416;
        double r233750 = r233748 + r233749;
        double r233751 = r233750 * r233741;
        double r233752 = y;
        double r233753 = r233751 + r233752;
        double r233754 = r233753 * r233741;
        double r233755 = z;
        double r233756 = r233754 + r233755;
        double r233757 = r233743 * r233756;
        double r233758 = 43.3400022514;
        double r233759 = r233741 + r233758;
        double r233760 = r233759 * r233741;
        double r233761 = 263.505074721;
        double r233762 = r233760 + r233761;
        double r233763 = r233762 * r233741;
        double r233764 = 313.399215894;
        double r233765 = r233763 + r233764;
        double r233766 = r233765 * r233741;
        double r233767 = 47.066876606;
        double r233768 = r233766 + r233767;
        double r233769 = r233757 / r233768;
        return r233769;
}

double f(double x, double y, double z) {
        double r233770 = x;
        double r233771 = -3.947481332209468e+38;
        bool r233772 = r233770 <= r233771;
        double r233773 = 2.0;
        double r233774 = r233770 - r233773;
        double r233775 = y;
        double r233776 = 3.0;
        double r233777 = pow(r233770, r233776);
        double r233778 = r233775 / r233777;
        double r233779 = 4.16438922228;
        double r233780 = r233778 + r233779;
        double r233781 = 101.7851458539211;
        double r233782 = r233781 / r233770;
        double r233783 = r233780 - r233782;
        double r233784 = r233774 * r233783;
        double r233785 = 9.98303336278828e+23;
        bool r233786 = r233770 <= r233785;
        double r233787 = pow(r233773, r233776);
        double r233788 = r233777 - r233787;
        double r233789 = 78.6994924154;
        double r233790 = fma(r233770, r233779, r233789);
        double r233791 = 137.519416416;
        double r233792 = fma(r233790, r233770, r233791);
        double r233793 = fma(r233792, r233770, r233775);
        double r233794 = z;
        double r233795 = fma(r233793, r233770, r233794);
        double r233796 = 43.3400022514;
        double r233797 = r233770 + r233796;
        double r233798 = 263.505074721;
        double r233799 = fma(r233797, r233770, r233798);
        double r233800 = 313.399215894;
        double r233801 = fma(r233799, r233770, r233800);
        double r233802 = 47.066876606;
        double r233803 = fma(r233801, r233770, r233802);
        double r233804 = r233795 / r233803;
        double r233805 = r233788 * r233804;
        double r233806 = r233770 * r233770;
        double r233807 = r233773 * r233773;
        double r233808 = r233770 * r233773;
        double r233809 = r233807 + r233808;
        double r233810 = r233806 + r233809;
        double r233811 = r233805 / r233810;
        double r233812 = 2.0;
        double r233813 = pow(r233770, r233812);
        double r233814 = r233775 / r233813;
        double r233815 = fma(r233779, r233770, r233814);
        double r233816 = 110.1139242984811;
        double r233817 = r233815 - r233816;
        double r233818 = r233786 ? r233811 : r233817;
        double r233819 = r233772 ? r233784 : r233818;
        return r233819;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original26.7
Target0.6
Herbie0.8
\[\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 3 regimes
  2. if x < -3.947481332209468e+38

    1. Initial program 60.4

      \[\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. Simplified56.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-inv56.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. Simplified56.5

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

      \[\leadsto \left(x - 2\right) \cdot \color{blue}{\left(\left(\frac{y}{{x}^{3}} + 4.16438922227999963610045597306452691555\right) - 101.785145853921093817007204052060842514 \cdot \frac{1}{x}\right)}\]
    7. Simplified0.7

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

    if -3.947481332209468e+38 < x < 9.98303336278828e+23

    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)}}\]

    if 9.98303336278828e+23 < x

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(4.16438922227999963610045597306452691555, x, \frac{y}{{x}^{2}}\right) - 110.1139242984810948655649553984403610229}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -394748133220946787888436044907157651456:\\ \;\;\;\;\left(x - 2\right) \cdot \left(\left(\frac{y}{{x}^{3}} + 4.16438922227999963610045597306452691555\right) - \frac{101.785145853921093817007204052060842514}{x}\right)\\ \mathbf{elif}\;x \le 998303336278827940708352:\\ \;\;\;\;\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)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(4.16438922227999963610045597306452691555, x, \frac{y}{{x}^{2}}\right) - 110.1139242984810948655649553984403610229\\ \end{array}\]

Reproduce

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