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 -1.040609210124971143267128441934146545775 \cdot 10^{67}:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \frac{y}{x \cdot x}\right) - 110.1139242984810948655649553984403610229\\ \mathbf{elif}\;x \le 3.780764592174215067932125008622059549997 \cdot 10^{68}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \sqrt[3]{\mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), 137.5194164160000127594685181975364685059\right)} \cdot \left(\sqrt[3]{\mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), 137.5194164160000127594685181975364685059\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), 137.5194164160000127594685181975364685059\right)}\right), y\right), z\right)}{\frac{\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}}\\ \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 -1.040609210124971143267128441934146545775 \cdot 10^{67}:\\
\;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \frac{y}{x \cdot x}\right) - 110.1139242984810948655649553984403610229\\

\mathbf{elif}\;x \le 3.780764592174215067932125008622059549997 \cdot 10^{68}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \sqrt[3]{\mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), 137.5194164160000127594685181975364685059\right)} \cdot \left(\sqrt[3]{\mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), 137.5194164160000127594685181975364685059\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), 137.5194164160000127594685181975364685059\right)}\right), y\right), z\right)}{\frac{\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}}\\

\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 r17137527 = x;
        double r17137528 = 2.0;
        double r17137529 = r17137527 - r17137528;
        double r17137530 = 4.16438922228;
        double r17137531 = r17137527 * r17137530;
        double r17137532 = 78.6994924154;
        double r17137533 = r17137531 + r17137532;
        double r17137534 = r17137533 * r17137527;
        double r17137535 = 137.519416416;
        double r17137536 = r17137534 + r17137535;
        double r17137537 = r17137536 * r17137527;
        double r17137538 = y;
        double r17137539 = r17137537 + r17137538;
        double r17137540 = r17137539 * r17137527;
        double r17137541 = z;
        double r17137542 = r17137540 + r17137541;
        double r17137543 = r17137529 * r17137542;
        double r17137544 = 43.3400022514;
        double r17137545 = r17137527 + r17137544;
        double r17137546 = r17137545 * r17137527;
        double r17137547 = 263.505074721;
        double r17137548 = r17137546 + r17137547;
        double r17137549 = r17137548 * r17137527;
        double r17137550 = 313.399215894;
        double r17137551 = r17137549 + r17137550;
        double r17137552 = r17137551 * r17137527;
        double r17137553 = 47.066876606;
        double r17137554 = r17137552 + r17137553;
        double r17137555 = r17137543 / r17137554;
        return r17137555;
}

double f(double x, double y, double z) {
        double r17137556 = x;
        double r17137557 = -1.0406092101249711e+67;
        bool r17137558 = r17137556 <= r17137557;
        double r17137559 = 4.16438922228;
        double r17137560 = y;
        double r17137561 = r17137556 * r17137556;
        double r17137562 = r17137560 / r17137561;
        double r17137563 = fma(r17137556, r17137559, r17137562);
        double r17137564 = 110.1139242984811;
        double r17137565 = r17137563 - r17137564;
        double r17137566 = 3.780764592174215e+68;
        bool r17137567 = r17137556 <= r17137566;
        double r17137568 = 78.6994924154;
        double r17137569 = fma(r17137556, r17137559, r17137568);
        double r17137570 = 137.519416416;
        double r17137571 = fma(r17137556, r17137569, r17137570);
        double r17137572 = cbrt(r17137571);
        double r17137573 = r17137572 * r17137572;
        double r17137574 = r17137572 * r17137573;
        double r17137575 = fma(r17137556, r17137574, r17137560);
        double r17137576 = z;
        double r17137577 = fma(r17137556, r17137575, r17137576);
        double r17137578 = 43.3400022514;
        double r17137579 = r17137578 + r17137556;
        double r17137580 = 263.505074721;
        double r17137581 = fma(r17137579, r17137556, r17137580);
        double r17137582 = 313.399215894;
        double r17137583 = fma(r17137581, r17137556, r17137582);
        double r17137584 = 47.066876606;
        double r17137585 = fma(r17137583, r17137556, r17137584);
        double r17137586 = 2.0;
        double r17137587 = r17137556 - r17137586;
        double r17137588 = r17137585 / r17137587;
        double r17137589 = r17137577 / r17137588;
        double r17137590 = r17137567 ? r17137589 : r17137565;
        double r17137591 = r17137558 ? r17137565 : r17137590;
        return r17137591;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original26.8
Target0.4
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.0406092101249711e+67 or 3.780764592174215e+68 < x

    1. Initial program 64.0

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

      \[\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)}{\frac{\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}}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity61.7

      \[\leadsto \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)}{\frac{\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}{1 \cdot \left(x - 2\right)}}}\]
    5. Applied add-sqr-sqrt61.7

      \[\leadsto \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)}{\frac{\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)}}}{1 \cdot \left(x - 2\right)}}\]
    6. Applied times-frac61.7

      \[\leadsto \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)}{\color{blue}{\frac{\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)}}{1} \cdot \frac{\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)}}{x - 2}}}\]
    7. Applied associate-/r*61.7

      \[\leadsto \color{blue}{\frac{\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)}{\frac{\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)}}{1}}}{\frac{\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)}}{x - 2}}}\]
    8. Using strategy rm
    9. Applied add-cbrt-cube61.7

      \[\leadsto \frac{\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)}{\frac{\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)}}{1}}}{\color{blue}{\sqrt[3]{\left(\frac{\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)}}{x - 2} \cdot \frac{\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)}}{x - 2}\right) \cdot \frac{\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)}}{x - 2}}}}\]
    10. Taylor expanded around inf 0.1

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

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

    if -1.0406092101249711e+67 < x < 3.780764592174215e+68

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

      \[\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)}{\frac{\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}}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt0.8

      \[\leadsto \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{\left(\sqrt[3]{\mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), 137.5194164160000127594685181975364685059\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), 137.5194164160000127594685181975364685059\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), 137.5194164160000127594685181975364685059\right)}}, y\right), z\right)}{\frac{\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}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.040609210124971143267128441934146545775 \cdot 10^{67}:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \frac{y}{x \cdot x}\right) - 110.1139242984810948655649553984403610229\\ \mathbf{elif}\;x \le 3.780764592174215067932125008622059549997 \cdot 10^{68}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \sqrt[3]{\mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), 137.5194164160000127594685181975364685059\right)} \cdot \left(\sqrt[3]{\mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), 137.5194164160000127594685181975364685059\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x, \mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, 78.69949241540000173245061887428164482117\right), 137.5194164160000127594685181975364685059\right)}\right), y\right), z\right)}{\frac{\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}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \frac{y}{x \cdot x}\right) - 110.1139242984810948655649553984403610229\\ \end{array}\]

Reproduce

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