Average Error: 27.4 → 0.9
Time: 26.4s
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 -4.54130501806106185525358024175399241783 \cdot 10^{76}:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \frac{\frac{y}{x}}{x} - 110.1139242984810806547102401964366436005\right)\\ \mathbf{elif}\;x \le 83933274782594010076530896400645466619900:\\ \;\;\;\;\frac{\left(x - 2\right) \cdot \left(\frac{1}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514000013984514225739985704422 + x, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}} \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)\right)}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514000013984514225739985704422 + x, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \frac{\frac{y}{x}}{x} - 110.1139242984810806547102401964366436005\right)\\ \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 -4.54130501806106185525358024175399241783 \cdot 10^{76}:\\
\;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \frac{\frac{y}{x}}{x} - 110.1139242984810806547102401964366436005\right)\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r18109550 = x;
        double r18109551 = 2.0;
        double r18109552 = r18109550 - r18109551;
        double r18109553 = 4.16438922228;
        double r18109554 = r18109550 * r18109553;
        double r18109555 = 78.6994924154;
        double r18109556 = r18109554 + r18109555;
        double r18109557 = r18109556 * r18109550;
        double r18109558 = 137.519416416;
        double r18109559 = r18109557 + r18109558;
        double r18109560 = r18109559 * r18109550;
        double r18109561 = y;
        double r18109562 = r18109560 + r18109561;
        double r18109563 = r18109562 * r18109550;
        double r18109564 = z;
        double r18109565 = r18109563 + r18109564;
        double r18109566 = r18109552 * r18109565;
        double r18109567 = 43.3400022514;
        double r18109568 = r18109550 + r18109567;
        double r18109569 = r18109568 * r18109550;
        double r18109570 = 263.505074721;
        double r18109571 = r18109569 + r18109570;
        double r18109572 = r18109571 * r18109550;
        double r18109573 = 313.399215894;
        double r18109574 = r18109572 + r18109573;
        double r18109575 = r18109574 * r18109550;
        double r18109576 = 47.066876606;
        double r18109577 = r18109575 + r18109576;
        double r18109578 = r18109566 / r18109577;
        return r18109578;
}

double f(double x, double y, double z) {
        double r18109579 = x;
        double r18109580 = -4.541305018061062e+76;
        bool r18109581 = r18109579 <= r18109580;
        double r18109582 = 4.16438922228;
        double r18109583 = y;
        double r18109584 = r18109583 / r18109579;
        double r18109585 = r18109584 / r18109579;
        double r18109586 = 110.11392429848108;
        double r18109587 = r18109585 - r18109586;
        double r18109588 = fma(r18109579, r18109582, r18109587);
        double r18109589 = 8.393327478259401e+40;
        bool r18109590 = r18109579 <= r18109589;
        double r18109591 = 2.0;
        double r18109592 = r18109579 - r18109591;
        double r18109593 = 1.0;
        double r18109594 = 43.3400022514;
        double r18109595 = r18109594 + r18109579;
        double r18109596 = 263.505074721;
        double r18109597 = fma(r18109595, r18109579, r18109596);
        double r18109598 = 313.399215894;
        double r18109599 = fma(r18109597, r18109579, r18109598);
        double r18109600 = 47.066876606;
        double r18109601 = fma(r18109599, r18109579, r18109600);
        double r18109602 = sqrt(r18109601);
        double r18109603 = r18109593 / r18109602;
        double r18109604 = 78.6994924154;
        double r18109605 = fma(r18109579, r18109582, r18109604);
        double r18109606 = 137.519416416;
        double r18109607 = fma(r18109579, r18109605, r18109606);
        double r18109608 = fma(r18109579, r18109607, r18109583);
        double r18109609 = z;
        double r18109610 = fma(r18109579, r18109608, r18109609);
        double r18109611 = r18109603 * r18109610;
        double r18109612 = r18109592 * r18109611;
        double r18109613 = r18109612 / r18109602;
        double r18109614 = r18109590 ? r18109613 : r18109588;
        double r18109615 = r18109581 ? r18109588 : r18109614;
        return r18109615;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original27.4
Target0.6
Herbie0.9
\[\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 < -4.541305018061062e+76 or 8.393327478259401e+40 < x

    1. Initial program 61.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. Simplified59.6

      \[\leadsto \color{blue}{\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) \cdot \frac{x - 2}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514000013984514225739985704422 + x, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}}\]
    3. Using strategy rm
    4. Applied flip--59.6

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

      \[\leadsto \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) \cdot \color{blue}{\frac{x \cdot x - 2 \cdot 2}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514000013984514225739985704422 + x, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right) \cdot \left(x + 2\right)}}\]
    6. Taylor expanded around inf 0.5

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

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

    if -4.541305018061062e+76 < x < 8.393327478259401e+40

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

      \[\leadsto \color{blue}{\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) \cdot \frac{x - 2}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514000013984514225739985704422 + x, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt1.3

      \[\leadsto \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) \cdot \frac{x - 2}{\color{blue}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514000013984514225739985704422 + x, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)} \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514000013984514225739985704422 + x, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}}}\]
    5. Applied *-un-lft-identity1.3

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

      \[\leadsto \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) \cdot \color{blue}{\left(\frac{1}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514000013984514225739985704422 + x, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}} \cdot \frac{x - 2}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514000013984514225739985704422 + x, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}}\right)}\]
    7. Applied associate-*r*1.3

      \[\leadsto \color{blue}{\left(\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) \cdot \frac{1}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514000013984514225739985704422 + x, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}}\right) \cdot \frac{x - 2}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514000013984514225739985704422 + x, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}}}\]
    8. Using strategy rm
    9. Applied associate-*r/1.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -4.54130501806106185525358024175399241783 \cdot 10^{76}:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \frac{\frac{y}{x}}{x} - 110.1139242984810806547102401964366436005\right)\\ \mathbf{elif}\;x \le 83933274782594010076530896400645466619900:\\ \;\;\;\;\frac{\left(x - 2\right) \cdot \left(\frac{1}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514000013984514225739985704422 + x, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}} \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)\right)}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514000013984514225739985704422 + x, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \frac{\frac{y}{x}}{x} - 110.1139242984810806547102401964366436005\right)\\ \end{array}\]

Reproduce

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