Average Error: 26.8 → 0.5
Time: 21.2s
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.914499972464791844188398177846978570663 \cdot 10^{71} \lor \neg \left(x \le 2.287943170826980441039975419814875490697 \cdot 10^{47}\right):\\ \;\;\;\;\left(x - 2\right) \cdot \left(\left(\frac{y}{{x}^{3}} + 4.16438922227999963610045597306452691555\right) - \frac{101.785145853921093817007204052060842514}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - 2\right) \cdot \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(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\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 -1.914499972464791844188398177846978570663 \cdot 10^{71} \lor \neg \left(x \le 2.287943170826980441039975419814875490697 \cdot 10^{47}\right):\\
\;\;\;\;\left(x - 2\right) \cdot \left(\left(\frac{y}{{x}^{3}} + 4.16438922227999963610045597306452691555\right) - \frac{101.785145853921093817007204052060842514}{x}\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r174398 = x;
        double r174399 = 2.0;
        double r174400 = r174398 - r174399;
        double r174401 = 4.16438922228;
        double r174402 = r174398 * r174401;
        double r174403 = 78.6994924154;
        double r174404 = r174402 + r174403;
        double r174405 = r174404 * r174398;
        double r174406 = 137.519416416;
        double r174407 = r174405 + r174406;
        double r174408 = r174407 * r174398;
        double r174409 = y;
        double r174410 = r174408 + r174409;
        double r174411 = r174410 * r174398;
        double r174412 = z;
        double r174413 = r174411 + r174412;
        double r174414 = r174400 * r174413;
        double r174415 = 43.3400022514;
        double r174416 = r174398 + r174415;
        double r174417 = r174416 * r174398;
        double r174418 = 263.505074721;
        double r174419 = r174417 + r174418;
        double r174420 = r174419 * r174398;
        double r174421 = 313.399215894;
        double r174422 = r174420 + r174421;
        double r174423 = r174422 * r174398;
        double r174424 = 47.066876606;
        double r174425 = r174423 + r174424;
        double r174426 = r174414 / r174425;
        return r174426;
}

double f(double x, double y, double z) {
        double r174427 = x;
        double r174428 = -1.9144999724647918e+71;
        bool r174429 = r174427 <= r174428;
        double r174430 = 2.2879431708269804e+47;
        bool r174431 = r174427 <= r174430;
        double r174432 = !r174431;
        bool r174433 = r174429 || r174432;
        double r174434 = 2.0;
        double r174435 = r174427 - r174434;
        double r174436 = y;
        double r174437 = 3.0;
        double r174438 = pow(r174427, r174437);
        double r174439 = r174436 / r174438;
        double r174440 = 4.16438922228;
        double r174441 = r174439 + r174440;
        double r174442 = 101.7851458539211;
        double r174443 = r174442 / r174427;
        double r174444 = r174441 - r174443;
        double r174445 = r174435 * r174444;
        double r174446 = 78.6994924154;
        double r174447 = fma(r174427, r174440, r174446);
        double r174448 = 137.519416416;
        double r174449 = fma(r174447, r174427, r174448);
        double r174450 = fma(r174449, r174427, r174436);
        double r174451 = z;
        double r174452 = fma(r174450, r174427, r174451);
        double r174453 = 43.3400022514;
        double r174454 = r174427 + r174453;
        double r174455 = 263.505074721;
        double r174456 = fma(r174454, r174427, r174455);
        double r174457 = 313.399215894;
        double r174458 = fma(r174456, r174427, r174457);
        double r174459 = 47.066876606;
        double r174460 = fma(r174458, r174427, r174459);
        double r174461 = r174452 / r174460;
        double r174462 = r174435 * r174461;
        double r174463 = r174433 ? r174445 : r174462;
        return r174463;
}

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.9144999724647918e+71 or 2.2879431708269804e+47 < x

    1. Initial program 62.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. Simplified60.0

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

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

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

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

      \[\leadsto \left(x - 2\right) \cdot \color{blue}{\left(\left(\frac{y}{{x}^{3}} + 4.16438922227999963610045597306452691555\right) - \frac{101.785145853921093817007204052060842514}{x}\right)}\]

    if -1.9144999724647918e+71 < x < 2.2879431708269804e+47

    1. Initial program 2.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.914499972464791844188398177846978570663 \cdot 10^{71} \lor \neg \left(x \le 2.287943170826980441039975419814875490697 \cdot 10^{47}\right):\\ \;\;\;\;\left(x - 2\right) \cdot \left(\left(\frac{y}{{x}^{3}} + 4.16438922227999963610045597306452691555\right) - \frac{101.785145853921093817007204052060842514}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - 2\right) \cdot \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(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000013984514225739985704422, x, 263.5050747210000281484099105000495910645\right), x, 313.3992158940000081202015280723571777344\right), x, 47.06687660600000100430406746454536914825\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2019326 +o rules:numerics
(FPCore (x y z)
  :name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, C"
  :precision binary64

  :herbie-target
  (if (< x -3.326128725870005e+62) (- (+ (/ y (* x x)) (* 4.16438922228 x)) 110.1139242984811) (if (< x 9.429991714554673e+55) (* (/ (- x 2) 1) (/ (+ (* (+ (* (+ (* (+ (* 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) (+ (* (+ (* (+ (* (+ (* x 4.16438922228) 78.6994924154) x) 137.519416416) x) y) x) z)) (+ (* (+ (* (+ (* (+ x 43.3400022514) x) 263.505074721) x) 313.399215894) x) 47.066876606)))