Average Error: 26.8 → 0.5
Time: 1.0m
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 -124741788221623399099317787892564199735300:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \frac{y}{x \cdot x}\right) - 110.1139242984810948655649553984403610229\\ \mathbf{elif}\;x \le 3.151281068729821565811535199772462844528 \cdot 10^{66}:\\ \;\;\;\;\left(x - 2\right) \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)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \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 -124741788221623399099317787892564199735300:\\
\;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \frac{y}{x \cdot x}\right) - 110.1139242984810948655649553984403610229\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r19618470 = x;
        double r19618471 = 2.0;
        double r19618472 = r19618470 - r19618471;
        double r19618473 = 4.16438922228;
        double r19618474 = r19618470 * r19618473;
        double r19618475 = 78.6994924154;
        double r19618476 = r19618474 + r19618475;
        double r19618477 = r19618476 * r19618470;
        double r19618478 = 137.519416416;
        double r19618479 = r19618477 + r19618478;
        double r19618480 = r19618479 * r19618470;
        double r19618481 = y;
        double r19618482 = r19618480 + r19618481;
        double r19618483 = r19618482 * r19618470;
        double r19618484 = z;
        double r19618485 = r19618483 + r19618484;
        double r19618486 = r19618472 * r19618485;
        double r19618487 = 43.3400022514;
        double r19618488 = r19618470 + r19618487;
        double r19618489 = r19618488 * r19618470;
        double r19618490 = 263.505074721;
        double r19618491 = r19618489 + r19618490;
        double r19618492 = r19618491 * r19618470;
        double r19618493 = 313.399215894;
        double r19618494 = r19618492 + r19618493;
        double r19618495 = r19618494 * r19618470;
        double r19618496 = 47.066876606;
        double r19618497 = r19618495 + r19618496;
        double r19618498 = r19618486 / r19618497;
        return r19618498;
}

double f(double x, double y, double z) {
        double r19618499 = x;
        double r19618500 = -1.247417882216234e+41;
        bool r19618501 = r19618499 <= r19618500;
        double r19618502 = 4.16438922228;
        double r19618503 = y;
        double r19618504 = r19618499 * r19618499;
        double r19618505 = r19618503 / r19618504;
        double r19618506 = fma(r19618499, r19618502, r19618505);
        double r19618507 = 110.1139242984811;
        double r19618508 = r19618506 - r19618507;
        double r19618509 = 3.1512810687298216e+66;
        bool r19618510 = r19618499 <= r19618509;
        double r19618511 = 2.0;
        double r19618512 = r19618499 - r19618511;
        double r19618513 = 78.6994924154;
        double r19618514 = fma(r19618499, r19618502, r19618513);
        double r19618515 = 137.519416416;
        double r19618516 = fma(r19618499, r19618514, r19618515);
        double r19618517 = fma(r19618499, r19618516, r19618503);
        double r19618518 = z;
        double r19618519 = fma(r19618499, r19618517, r19618518);
        double r19618520 = 43.3400022514;
        double r19618521 = r19618499 + r19618520;
        double r19618522 = 263.505074721;
        double r19618523 = fma(r19618521, r19618499, r19618522);
        double r19618524 = 313.399215894;
        double r19618525 = fma(r19618523, r19618499, r19618524);
        double r19618526 = 47.066876606;
        double r19618527 = fma(r19618525, r19618499, r19618526);
        double r19618528 = r19618519 / r19618527;
        double r19618529 = r19618512 * r19618528;
        double r19618530 = r19618510 ? r19618529 : r19618508;
        double r19618531 = r19618501 ? r19618508 : r19618530;
        return r19618531;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original26.8
Target0.5
Herbie0.5
\[\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.247417882216234e+41 or 3.1512810687298216e+66 < x

    1. Initial program 62.2

      \[\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. Simplified58.9

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

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

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

    if -1.247417882216234e+41 < x < 3.1512810687298216e+66

    1. Initial program 1.6

      \[\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.9

      \[\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 div-sub0.9

      \[\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{x}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(43.3400022514000013984514225739985704422 + x, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)} - \frac{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)}\right)}\]
    5. Using strategy rm
    6. Applied div-inv0.9

      \[\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 \left(\frac{x}{\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}{2 \cdot \frac{1}{\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 div-inv0.9

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

      \[\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}{\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)\right)}\]
    9. Applied associate-*r*0.9

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

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

Reproduce

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