Average Error: 26.8 → 1.2
Time: 23.6s
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 -63731115738061960:\\ \;\;\;\;\mathsf{fma}\left(4.16438922227999963610045597306452691555, x, \frac{y}{x \cdot x} - 110.1139242984810948655649553984403610229\right)\\ \mathbf{elif}\;x \le 2133877352683455907745679184412803072:\\ \;\;\;\;\sqrt{\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(\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(\sqrt{\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)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(4.16438922227999963610045597306452691555, x, \frac{y}{x \cdot x} - 110.1139242984810948655649553984403610229\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 -63731115738061960:\\
\;\;\;\;\mathsf{fma}\left(4.16438922227999963610045597306452691555, x, \frac{y}{x \cdot x} - 110.1139242984810948655649553984403610229\right)\\

\mathbf{elif}\;x \le 2133877352683455907745679184412803072:\\
\;\;\;\;\sqrt{\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(\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(\sqrt{\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)\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r22225425 = x;
        double r22225426 = 2.0;
        double r22225427 = r22225425 - r22225426;
        double r22225428 = 4.16438922228;
        double r22225429 = r22225425 * r22225428;
        double r22225430 = 78.6994924154;
        double r22225431 = r22225429 + r22225430;
        double r22225432 = r22225431 * r22225425;
        double r22225433 = 137.519416416;
        double r22225434 = r22225432 + r22225433;
        double r22225435 = r22225434 * r22225425;
        double r22225436 = y;
        double r22225437 = r22225435 + r22225436;
        double r22225438 = r22225437 * r22225425;
        double r22225439 = z;
        double r22225440 = r22225438 + r22225439;
        double r22225441 = r22225427 * r22225440;
        double r22225442 = 43.3400022514;
        double r22225443 = r22225425 + r22225442;
        double r22225444 = r22225443 * r22225425;
        double r22225445 = 263.505074721;
        double r22225446 = r22225444 + r22225445;
        double r22225447 = r22225446 * r22225425;
        double r22225448 = 313.399215894;
        double r22225449 = r22225447 + r22225448;
        double r22225450 = r22225449 * r22225425;
        double r22225451 = 47.066876606;
        double r22225452 = r22225450 + r22225451;
        double r22225453 = r22225441 / r22225452;
        return r22225453;
}

double f(double x, double y, double z) {
        double r22225454 = x;
        double r22225455 = -6.373111573806196e+16;
        bool r22225456 = r22225454 <= r22225455;
        double r22225457 = 4.16438922228;
        double r22225458 = y;
        double r22225459 = r22225454 * r22225454;
        double r22225460 = r22225458 / r22225459;
        double r22225461 = 110.1139242984811;
        double r22225462 = r22225460 - r22225461;
        double r22225463 = fma(r22225457, r22225454, r22225462);
        double r22225464 = 2.133877352683456e+36;
        bool r22225465 = r22225454 <= r22225464;
        double r22225466 = 1.0;
        double r22225467 = 43.3400022514;
        double r22225468 = r22225467 + r22225454;
        double r22225469 = 263.505074721;
        double r22225470 = fma(r22225468, r22225454, r22225469);
        double r22225471 = 313.399215894;
        double r22225472 = fma(r22225470, r22225454, r22225471);
        double r22225473 = 47.066876606;
        double r22225474 = fma(r22225472, r22225454, r22225473);
        double r22225475 = r22225466 / r22225474;
        double r22225476 = sqrt(r22225475);
        double r22225477 = 78.6994924154;
        double r22225478 = fma(r22225454, r22225457, r22225477);
        double r22225479 = 137.519416416;
        double r22225480 = fma(r22225454, r22225478, r22225479);
        double r22225481 = fma(r22225454, r22225480, r22225458);
        double r22225482 = z;
        double r22225483 = fma(r22225454, r22225481, r22225482);
        double r22225484 = 2.0;
        double r22225485 = r22225454 - r22225484;
        double r22225486 = r22225476 * r22225485;
        double r22225487 = r22225483 * r22225486;
        double r22225488 = r22225476 * r22225487;
        double r22225489 = r22225465 ? r22225488 : r22225463;
        double r22225490 = r22225456 ? r22225463 : r22225489;
        return r22225490;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original26.8
Target0.6
Herbie1.2
\[\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.373111573806196e+16 or 2.133877352683456e+36 < x

    1. Initial program 57.9

      \[\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. Simplified54.0

      \[\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-inv54.0

      \[\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(\left(x - 2\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)}\]
    5. Using strategy rm
    6. Applied flip--54.0

      \[\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}{\frac{x \cdot x - 2 \cdot 2}{x + 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 associate-*l/54.0

      \[\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{\left(x \cdot x - 2 \cdot 2\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)}}{x + 2}}\]
    8. Simplified54.0

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

      \[\leadsto \color{blue}{\left(\frac{y}{{x}^{2}} + 4.16438922227999963610045597306452691555 \cdot x\right) - 110.1139242984810948655649553984403610229}\]
    10. Simplified1.8

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

    if -6.373111573806196e+16 < x < 2.133877352683456e+36

    1. Initial program 0.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.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 div-inv0.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 \color{blue}{\left(\left(x - 2\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)}\]
    5. Using strategy rm
    6. Applied add-sqr-sqrt0.8

      \[\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(\left(x - 2\right) \cdot \color{blue}{\left(\sqrt{\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 \sqrt{\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)}\right)\]
    7. Applied associate-*r*0.8

      \[\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(\left(\left(x - 2\right) \cdot \sqrt{\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 \sqrt{\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. Using strategy rm
    9. Applied associate-*r*0.7

      \[\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 \left(\left(x - 2\right) \cdot \sqrt{\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)\right) \cdot \sqrt{\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)}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -63731115738061960:\\ \;\;\;\;\mathsf{fma}\left(4.16438922227999963610045597306452691555, x, \frac{y}{x \cdot x} - 110.1139242984810948655649553984403610229\right)\\ \mathbf{elif}\;x \le 2133877352683455907745679184412803072:\\ \;\;\;\;\sqrt{\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(\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(\sqrt{\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)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(4.16438922227999963610045597306452691555, x, \frac{y}{x \cdot x} - 110.1139242984810948655649553984403610229\right)\\ \end{array}\]

Reproduce

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