Average Error: 26.9 → 1.1
Time: 31.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 -63074748513986640340139900928:\\ \;\;\;\;\mathsf{fma}\left(4.16438922227999963610045597306452691555, x, \frac{y}{x \cdot x}\right) - 110.1139242984810948655649553984403610229\\ \mathbf{elif}\;x \le 620615997107907.625:\\ \;\;\;\;\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(x, \mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), 47.06687660600000100430406746454536914825\right)} \cdot \left(x - 2\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(4.16438922227999963610045597306452691555, x, \frac{y}{x \cdot x}\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 -63074748513986640340139900928:\\
\;\;\;\;\mathsf{fma}\left(4.16438922227999963610045597306452691555, x, \frac{y}{x \cdot x}\right) - 110.1139242984810948655649553984403610229\\

\mathbf{elif}\;x \le 620615997107907.625:\\
\;\;\;\;\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(x, \mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), 47.06687660600000100430406746454536914825\right)} \cdot \left(x - 2\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r23347559 = x;
        double r23347560 = 2.0;
        double r23347561 = r23347559 - r23347560;
        double r23347562 = 4.16438922228;
        double r23347563 = r23347559 * r23347562;
        double r23347564 = 78.6994924154;
        double r23347565 = r23347563 + r23347564;
        double r23347566 = r23347565 * r23347559;
        double r23347567 = 137.519416416;
        double r23347568 = r23347566 + r23347567;
        double r23347569 = r23347568 * r23347559;
        double r23347570 = y;
        double r23347571 = r23347569 + r23347570;
        double r23347572 = r23347571 * r23347559;
        double r23347573 = z;
        double r23347574 = r23347572 + r23347573;
        double r23347575 = r23347561 * r23347574;
        double r23347576 = 43.3400022514;
        double r23347577 = r23347559 + r23347576;
        double r23347578 = r23347577 * r23347559;
        double r23347579 = 263.505074721;
        double r23347580 = r23347578 + r23347579;
        double r23347581 = r23347580 * r23347559;
        double r23347582 = 313.399215894;
        double r23347583 = r23347581 + r23347582;
        double r23347584 = r23347583 * r23347559;
        double r23347585 = 47.066876606;
        double r23347586 = r23347584 + r23347585;
        double r23347587 = r23347575 / r23347586;
        return r23347587;
}

double f(double x, double y, double z) {
        double r23347588 = x;
        double r23347589 = -6.307474851398664e+28;
        bool r23347590 = r23347588 <= r23347589;
        double r23347591 = 4.16438922228;
        double r23347592 = y;
        double r23347593 = r23347588 * r23347588;
        double r23347594 = r23347592 / r23347593;
        double r23347595 = fma(r23347591, r23347588, r23347594);
        double r23347596 = 110.1139242984811;
        double r23347597 = r23347595 - r23347596;
        double r23347598 = 620615997107907.6;
        bool r23347599 = r23347588 <= r23347598;
        double r23347600 = 78.6994924154;
        double r23347601 = fma(r23347588, r23347591, r23347600);
        double r23347602 = 137.519416416;
        double r23347603 = fma(r23347601, r23347588, r23347602);
        double r23347604 = fma(r23347603, r23347588, r23347592);
        double r23347605 = z;
        double r23347606 = fma(r23347604, r23347588, r23347605);
        double r23347607 = 43.3400022514;
        double r23347608 = r23347588 + r23347607;
        double r23347609 = 263.505074721;
        double r23347610 = fma(r23347608, r23347588, r23347609);
        double r23347611 = 313.399215894;
        double r23347612 = fma(r23347610, r23347588, r23347611);
        double r23347613 = 47.066876606;
        double r23347614 = fma(r23347588, r23347612, r23347613);
        double r23347615 = r23347606 / r23347614;
        double r23347616 = 2.0;
        double r23347617 = r23347588 - r23347616;
        double r23347618 = r23347615 * r23347617;
        double r23347619 = r23347599 ? r23347618 : r23347597;
        double r23347620 = r23347590 ? r23347597 : r23347619;
        return r23347620;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original26.9
Target0.6
Herbie1.1
\[\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.307474851398664e+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{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.1

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

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

    if -6.307474851398664e+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.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. Using strategy rm
    6. Applied *-un-lft-identity0.5

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

      \[\leadsto \left(x - 2\right) \cdot \frac{1}{\frac{\color{blue}{1 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}}{1 \cdot \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)}}\]
    8. Applied times-frac0.5

      \[\leadsto \left(x - 2\right) \cdot \frac{1}{\color{blue}{\frac{1}{1} \cdot \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)}}}\]
    9. Applied add-cube-cbrt0.5

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

      \[\leadsto \left(x - 2\right) \cdot \color{blue}{\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{1}{1}} \cdot \frac{\sqrt[3]{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)}}\right)}\]
    11. Simplified0.5

      \[\leadsto \left(x - 2\right) \cdot \left(\color{blue}{1} \cdot \frac{\sqrt[3]{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)}}\right)\]
    12. Simplified0.3

      \[\leadsto \left(x - 2\right) \cdot \left(1 \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(x, \mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), 47.06687660600000100430406746454536914825\right)}}\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -63074748513986640340139900928:\\ \;\;\;\;\mathsf{fma}\left(4.16438922227999963610045597306452691555, x, \frac{y}{x \cdot x}\right) - 110.1139242984810948655649553984403610229\\ \mathbf{elif}\;x \le 620615997107907.625:\\ \;\;\;\;\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(x, \mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), 47.06687660600000100430406746454536914825\right)} \cdot \left(x - 2\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(4.16438922227999963610045597306452691555, x, \frac{y}{x \cdot x}\right) - 110.1139242984810948655649553984403610229\\ \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)))