Average Error: 26.1 → 0.7
Time: 57.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 -1.486655794493063927988268380417398027792 \cdot 10^{52}:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \frac{y}{x \cdot x}\right) - 110.1139242984810806547102401964366436005\\ \mathbf{elif}\;x \le 1.849715130765958258047258630293245781501 \cdot 10^{53}:\\ \;\;\;\;\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)}{x + 2} \cdot \frac{1}{\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}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \frac{y}{x \cdot x}\right) - 110.1139242984810806547102401964366436005\\ \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 -1.486655794493063927988268380417398027792 \cdot 10^{52}:\\
\;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \frac{y}{x \cdot x}\right) - 110.1139242984810806547102401964366436005\\

\mathbf{elif}\;x \le 1.849715130765958258047258630293245781501 \cdot 10^{53}:\\
\;\;\;\;\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)}{x + 2} \cdot \frac{1}{\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}}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \frac{y}{x \cdot x}\right) - 110.1139242984810806547102401964366436005\\

\end{array}
double f(double x, double y, double z) {
        double r15844634 = x;
        double r15844635 = 2.0;
        double r15844636 = r15844634 - r15844635;
        double r15844637 = 4.16438922228;
        double r15844638 = r15844634 * r15844637;
        double r15844639 = 78.6994924154;
        double r15844640 = r15844638 + r15844639;
        double r15844641 = r15844640 * r15844634;
        double r15844642 = 137.519416416;
        double r15844643 = r15844641 + r15844642;
        double r15844644 = r15844643 * r15844634;
        double r15844645 = y;
        double r15844646 = r15844644 + r15844645;
        double r15844647 = r15844646 * r15844634;
        double r15844648 = z;
        double r15844649 = r15844647 + r15844648;
        double r15844650 = r15844636 * r15844649;
        double r15844651 = 43.3400022514;
        double r15844652 = r15844634 + r15844651;
        double r15844653 = r15844652 * r15844634;
        double r15844654 = 263.505074721;
        double r15844655 = r15844653 + r15844654;
        double r15844656 = r15844655 * r15844634;
        double r15844657 = 313.399215894;
        double r15844658 = r15844656 + r15844657;
        double r15844659 = r15844658 * r15844634;
        double r15844660 = 47.066876606;
        double r15844661 = r15844659 + r15844660;
        double r15844662 = r15844650 / r15844661;
        return r15844662;
}

double f(double x, double y, double z) {
        double r15844663 = x;
        double r15844664 = -1.486655794493064e+52;
        bool r15844665 = r15844663 <= r15844664;
        double r15844666 = 4.16438922228;
        double r15844667 = y;
        double r15844668 = r15844663 * r15844663;
        double r15844669 = r15844667 / r15844668;
        double r15844670 = fma(r15844663, r15844666, r15844669);
        double r15844671 = 110.11392429848108;
        double r15844672 = r15844670 - r15844671;
        double r15844673 = 1.8497151307659583e+53;
        bool r15844674 = r15844663 <= r15844673;
        double r15844675 = 78.6994924154;
        double r15844676 = fma(r15844663, r15844666, r15844675);
        double r15844677 = 137.519416416;
        double r15844678 = fma(r15844663, r15844676, r15844677);
        double r15844679 = fma(r15844663, r15844678, r15844667);
        double r15844680 = z;
        double r15844681 = fma(r15844663, r15844679, r15844680);
        double r15844682 = 2.0;
        double r15844683 = r15844663 + r15844682;
        double r15844684 = r15844681 / r15844683;
        double r15844685 = 1.0;
        double r15844686 = 43.3400022514;
        double r15844687 = r15844686 + r15844663;
        double r15844688 = 263.505074721;
        double r15844689 = fma(r15844687, r15844663, r15844688);
        double r15844690 = 313.399215894;
        double r15844691 = fma(r15844689, r15844663, r15844690);
        double r15844692 = 47.066876606;
        double r15844693 = fma(r15844691, r15844663, r15844692);
        double r15844694 = r15844682 * r15844682;
        double r15844695 = r15844668 - r15844694;
        double r15844696 = r15844693 / r15844695;
        double r15844697 = r15844685 / r15844696;
        double r15844698 = r15844684 * r15844697;
        double r15844699 = r15844674 ? r15844698 : r15844672;
        double r15844700 = r15844665 ? r15844672 : r15844699;
        return r15844700;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original26.1
Target0.5
Herbie0.7
\[\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 < -1.486655794493064e+52 or 1.8497151307659583e+53 < x

    1. Initial program 62.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. Simplified59.2

      \[\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 flip--59.2

      \[\leadsto \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)}{\color{blue}{\frac{x \cdot x - 2 \cdot 2}{x + 2}}}}\]
    5. Applied associate-/r/59.2

      \[\leadsto \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)}{\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)}}\]
    6. Applied *-un-lft-identity59.2

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

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

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

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

    if -1.486655794493064e+52 < x < 1.8497151307659583e+53

    1. Initial program 1.3

      \[\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{\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 flip--0.5

      \[\leadsto \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)}{\color{blue}{\frac{x \cdot x - 2 \cdot 2}{x + 2}}}}\]
    5. Applied associate-/r/0.5

      \[\leadsto \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)}{\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)}}\]
    6. Applied *-un-lft-identity0.5

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

      \[\leadsto \color{blue}{\frac{1}{\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 \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)}{x + 2}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.486655794493063927988268380417398027792 \cdot 10^{52}:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \frac{y}{x \cdot x}\right) - 110.1139242984810806547102401964366436005\\ \mathbf{elif}\;x \le 1.849715130765958258047258630293245781501 \cdot 10^{53}:\\ \;\;\;\;\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)}{x + 2} \cdot \frac{1}{\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}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \frac{y}{x \cdot x}\right) - 110.1139242984810806547102401964366436005\\ \end{array}\]

Reproduce

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