Average Error: 26.5 → 0.6
Time: 21.3s
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 -5.657540384046955638503103437127492884033 \cdot 10^{70} \lor \neg \left(x \le 2.326727261056874248511482631265264838987 \cdot 10^{74}\right):\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \frac{y}{{x}^{2}}\right) - 110.1139242984810948655649553984403610229\\ \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 -5.657540384046955638503103437127492884033 \cdot 10^{70} \lor \neg \left(x \le 2.326727261056874248511482631265264838987 \cdot 10^{74}\right):\\
\;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \frac{y}{{x}^{2}}\right) - 110.1139242984810948655649553984403610229\\

\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 r262465 = x;
        double r262466 = 2.0;
        double r262467 = r262465 - r262466;
        double r262468 = 4.16438922228;
        double r262469 = r262465 * r262468;
        double r262470 = 78.6994924154;
        double r262471 = r262469 + r262470;
        double r262472 = r262471 * r262465;
        double r262473 = 137.519416416;
        double r262474 = r262472 + r262473;
        double r262475 = r262474 * r262465;
        double r262476 = y;
        double r262477 = r262475 + r262476;
        double r262478 = r262477 * r262465;
        double r262479 = z;
        double r262480 = r262478 + r262479;
        double r262481 = r262467 * r262480;
        double r262482 = 43.3400022514;
        double r262483 = r262465 + r262482;
        double r262484 = r262483 * r262465;
        double r262485 = 263.505074721;
        double r262486 = r262484 + r262485;
        double r262487 = r262486 * r262465;
        double r262488 = 313.399215894;
        double r262489 = r262487 + r262488;
        double r262490 = r262489 * r262465;
        double r262491 = 47.066876606;
        double r262492 = r262490 + r262491;
        double r262493 = r262481 / r262492;
        return r262493;
}

double f(double x, double y, double z) {
        double r262494 = x;
        double r262495 = -5.657540384046956e+70;
        bool r262496 = r262494 <= r262495;
        double r262497 = 2.326727261056874e+74;
        bool r262498 = r262494 <= r262497;
        double r262499 = !r262498;
        bool r262500 = r262496 || r262499;
        double r262501 = 4.16438922228;
        double r262502 = y;
        double r262503 = 2.0;
        double r262504 = pow(r262494, r262503);
        double r262505 = r262502 / r262504;
        double r262506 = fma(r262494, r262501, r262505);
        double r262507 = 110.1139242984811;
        double r262508 = r262506 - r262507;
        double r262509 = 2.0;
        double r262510 = r262494 - r262509;
        double r262511 = 78.6994924154;
        double r262512 = fma(r262494, r262501, r262511);
        double r262513 = 137.519416416;
        double r262514 = fma(r262512, r262494, r262513);
        double r262515 = fma(r262514, r262494, r262502);
        double r262516 = z;
        double r262517 = fma(r262515, r262494, r262516);
        double r262518 = 43.3400022514;
        double r262519 = r262494 + r262518;
        double r262520 = 263.505074721;
        double r262521 = fma(r262519, r262494, r262520);
        double r262522 = 313.399215894;
        double r262523 = fma(r262521, r262494, r262522);
        double r262524 = 47.066876606;
        double r262525 = fma(r262523, r262494, r262524);
        double r262526 = r262517 / r262525;
        double r262527 = r262510 * r262526;
        double r262528 = r262500 ? r262508 : r262527;
        return r262528;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original26.5
Target0.5
Herbie0.6
\[\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 < -5.657540384046956e+70 or 2.326727261056874e+74 < 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. Simplified63.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 clear-num63.0

      \[\leadsto \frac{x - 2}{\color{blue}{\frac{1}{\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)}}}}\]
    5. Taylor expanded around inf 0.0

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

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

    if -5.657540384046956e+70 < x < 2.326727261056874e+74

    1. Initial program 3.5

      \[\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}{\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 clear-num1.0

      \[\leadsto \frac{x - 2}{\color{blue}{\frac{1}{\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)}}}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity1.0

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

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

      \[\leadsto \frac{x - 2}{\frac{1}{\color{blue}{\frac{1}{1} \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)}}}}\]
    9. Applied add-cube-cbrt1.0

      \[\leadsto \frac{x - 2}{\frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{1}{1} \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)}}}\]
    10. Applied times-frac1.0

      \[\leadsto \frac{x - 2}{\color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{1}{1}} \cdot \frac{\sqrt[3]{1}}{\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)}}}}\]
    11. Applied *-un-lft-identity1.0

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x - 2\right)}}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{1}{1}} \cdot \frac{\sqrt[3]{1}}{\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)}}}\]
    12. Applied times-frac1.0

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{1}{1}}} \cdot \frac{x - 2}{\frac{\sqrt[3]{1}}{\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)}}}}\]
    13. Simplified1.0

      \[\leadsto \color{blue}{1} \cdot \frac{x - 2}{\frac{\sqrt[3]{1}}{\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)}}}\]
    14. Simplified0.9

      \[\leadsto 1 \cdot \color{blue}{\left(\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)}\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -5.657540384046955638503103437127492884033 \cdot 10^{70} \lor \neg \left(x \le 2.326727261056874248511482631265264838987 \cdot 10^{74}\right):\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999963610045597306452691555, \frac{y}{{x}^{2}}\right) - 110.1139242984810948655649553984403610229\\ \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 2019305 +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.3261287258700048e62) (- (+ (/ y (* x x)) (* 4.16438922227999964 x)) 110.11392429848109) (if (< x 9.4299917145546727e55) (* (/ (- x 2) 1) (/ (+ (* (+ (* (+ (* (+ (* x 4.16438922227999964) 78.6994924154000017) x) 137.51941641600001) x) y) x) z) (+ (* (+ (+ (* 263.50507472100003 x) (+ (* 43.3400022514000014 (* x x)) (* x (* x x)))) 313.399215894) x) 47.066876606000001))) (- (+ (/ y (* x x)) (* 4.16438922227999964 x)) 110.11392429848109)))

  (/ (* (- x 2) (+ (* (+ (* (+ (* (+ (* x 4.16438922227999964) 78.6994924154000017) x) 137.51941641600001) x) y) x) z)) (+ (* (+ (* (+ (* (+ x 43.3400022514000014) x) 263.50507472100003) x) 313.399215894) x) 47.066876606000001)))