Average Error: 26.7 → 0.8
Time: 22.3s
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 r281736 = x;
        double r281737 = 2.0;
        double r281738 = r281736 - r281737;
        double r281739 = 4.16438922228;
        double r281740 = r281736 * r281739;
        double r281741 = 78.6994924154;
        double r281742 = r281740 + r281741;
        double r281743 = r281742 * r281736;
        double r281744 = 137.519416416;
        double r281745 = r281743 + r281744;
        double r281746 = r281745 * r281736;
        double r281747 = y;
        double r281748 = r281746 + r281747;
        double r281749 = r281748 * r281736;
        double r281750 = z;
        double r281751 = r281749 + r281750;
        double r281752 = r281738 * r281751;
        double r281753 = 43.3400022514;
        double r281754 = r281736 + r281753;
        double r281755 = r281754 * r281736;
        double r281756 = 263.505074721;
        double r281757 = r281755 + r281756;
        double r281758 = r281757 * r281736;
        double r281759 = 313.399215894;
        double r281760 = r281758 + r281759;
        double r281761 = r281760 * r281736;
        double r281762 = 47.066876606;
        double r281763 = r281761 + r281762;
        double r281764 = r281752 / r281763;
        return r281764;
}

double f(double x, double y, double z) {
        double r281765 = x;
        double r281766 = -3.947481332209468e+38;
        bool r281767 = r281765 <= r281766;
        double r281768 = 2.0;
        double r281769 = r281765 - r281768;
        double r281770 = y;
        double r281771 = 3.0;
        double r281772 = pow(r281765, r281771);
        double r281773 = r281770 / r281772;
        double r281774 = 4.16438922228;
        double r281775 = r281773 + r281774;
        double r281776 = 101.7851458539211;
        double r281777 = r281776 / r281765;
        double r281778 = r281775 - r281777;
        double r281779 = r281769 * r281778;
        double r281780 = 9.98303336278828e+23;
        bool r281781 = r281765 <= r281780;
        double r281782 = pow(r281768, r281771);
        double r281783 = r281772 - r281782;
        double r281784 = 78.6994924154;
        double r281785 = fma(r281765, r281774, r281784);
        double r281786 = 137.519416416;
        double r281787 = fma(r281785, r281765, r281786);
        double r281788 = fma(r281787, r281765, r281770);
        double r281789 = z;
        double r281790 = fma(r281788, r281765, r281789);
        double r281791 = 43.3400022514;
        double r281792 = r281765 + r281791;
        double r281793 = 263.505074721;
        double r281794 = fma(r281792, r281765, r281793);
        double r281795 = 313.399215894;
        double r281796 = fma(r281794, r281765, r281795);
        double r281797 = 47.066876606;
        double r281798 = fma(r281796, r281765, r281797);
        double r281799 = r281790 / r281798;
        double r281800 = r281783 * r281799;
        double r281801 = r281765 * r281765;
        double r281802 = r281768 * r281768;
        double r281803 = r281765 * r281768;
        double r281804 = r281802 + r281803;
        double r281805 = r281801 + r281804;
        double r281806 = r281800 / r281805;
        double r281807 = 2.0;
        double r281808 = pow(r281765, r281807);
        double r281809 = r281770 / r281808;
        double r281810 = fma(r281774, r281765, r281809);
        double r281811 = 110.1139242984811;
        double r281812 = r281810 - r281811;
        double r281813 = r281781 ? r281806 : r281812;
        double r281814 = r281767 ? r281779 : r281813;
        return r281814;
}

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)))