Average Error: 26.8 → 0.9
Time: 11.0s
Precision: 64
\[\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999964 + 78.6994924154000017\right) \cdot x + 137.51941641600001\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000014\right) \cdot x + 263.50507472100003\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606000001}\]
\[\begin{array}{l} \mathbf{if}\;x \le -5554983803297941420000 \lor \neg \left(x \le 9.45282792698044778 \cdot 10^{52}\right):\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}} - 110.113924298481081\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot x - 2 \cdot 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)} \cdot \left(x + 2\right)}\\ \end{array}\]
\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999964 + 78.6994924154000017\right) \cdot x + 137.51941641600001\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000014\right) \cdot x + 263.50507472100003\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606000001}
\begin{array}{l}
\mathbf{if}\;x \le -5554983803297941420000 \lor \neg \left(x \le 9.45282792698044778 \cdot 10^{52}\right):\\
\;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}} - 110.113924298481081\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot x - 2 \cdot 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)} \cdot \left(x + 2\right)}\\

\end{array}
double f(double x, double y, double z) {
        double r332642 = x;
        double r332643 = 2.0;
        double r332644 = r332642 - r332643;
        double r332645 = 4.16438922228;
        double r332646 = r332642 * r332645;
        double r332647 = 78.6994924154;
        double r332648 = r332646 + r332647;
        double r332649 = r332648 * r332642;
        double r332650 = 137.519416416;
        double r332651 = r332649 + r332650;
        double r332652 = r332651 * r332642;
        double r332653 = y;
        double r332654 = r332652 + r332653;
        double r332655 = r332654 * r332642;
        double r332656 = z;
        double r332657 = r332655 + r332656;
        double r332658 = r332644 * r332657;
        double r332659 = 43.3400022514;
        double r332660 = r332642 + r332659;
        double r332661 = r332660 * r332642;
        double r332662 = 263.505074721;
        double r332663 = r332661 + r332662;
        double r332664 = r332663 * r332642;
        double r332665 = 313.399215894;
        double r332666 = r332664 + r332665;
        double r332667 = r332666 * r332642;
        double r332668 = 47.066876606;
        double r332669 = r332667 + r332668;
        double r332670 = r332658 / r332669;
        return r332670;
}

double f(double x, double y, double z) {
        double r332671 = x;
        double r332672 = -5.554983803297941e+21;
        bool r332673 = r332671 <= r332672;
        double r332674 = 9.452827926980448e+52;
        bool r332675 = r332671 <= r332674;
        double r332676 = !r332675;
        bool r332677 = r332673 || r332676;
        double r332678 = 4.16438922228;
        double r332679 = y;
        double r332680 = 2.0;
        double r332681 = pow(r332671, r332680);
        double r332682 = r332679 / r332681;
        double r332683 = 110.11392429848108;
        double r332684 = r332682 - r332683;
        double r332685 = fma(r332671, r332678, r332684);
        double r332686 = r332671 * r332671;
        double r332687 = 2.0;
        double r332688 = r332687 * r332687;
        double r332689 = r332686 - r332688;
        double r332690 = 43.3400022514;
        double r332691 = r332671 + r332690;
        double r332692 = 263.505074721;
        double r332693 = fma(r332691, r332671, r332692);
        double r332694 = 313.399215894;
        double r332695 = fma(r332693, r332671, r332694);
        double r332696 = 47.066876606;
        double r332697 = fma(r332695, r332671, r332696);
        double r332698 = 78.6994924154;
        double r332699 = fma(r332671, r332678, r332698);
        double r332700 = 137.519416416;
        double r332701 = fma(r332699, r332671, r332700);
        double r332702 = fma(r332701, r332671, r332679);
        double r332703 = z;
        double r332704 = fma(r332702, r332671, r332703);
        double r332705 = r332697 / r332704;
        double r332706 = r332671 + r332687;
        double r332707 = r332705 * r332706;
        double r332708 = r332689 / r332707;
        double r332709 = r332677 ? r332685 : r332708;
        return r332709;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original26.8
Target0.5
Herbie0.9
\[\begin{array}{l} \mathbf{if}\;x \lt -3.3261287258700048 \cdot 10^{62}:\\ \;\;\;\;\left(\frac{y}{x \cdot x} + 4.16438922227999964 \cdot x\right) - 110.11392429848109\\ \mathbf{elif}\;x \lt 9.4299917145546727 \cdot 10^{55}:\\ \;\;\;\;\frac{x - 2}{1} \cdot \frac{\left(\left(\left(x \cdot 4.16438922227999964 + 78.6994924154000017\right) \cdot x + 137.51941641600001\right) \cdot x + y\right) \cdot x + z}{\left(\left(263.50507472100003 \cdot x + \left(43.3400022514000014 \cdot \left(x \cdot x\right) + x \cdot \left(x \cdot x\right)\right)\right) + 313.399215894\right) \cdot x + 47.066876606000001}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{y}{x \cdot x} + 4.16438922227999964 \cdot x\right) - 110.11392429848109\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -5.554983803297941e+21 or 9.452827926980448e+52 < x

    1. Initial program 59.7

      \[\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999964 + 78.6994924154000017\right) \cdot x + 137.51941641600001\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000014\right) \cdot x + 263.50507472100003\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606000001}\]
    2. Simplified55.4

      \[\leadsto \color{blue}{\frac{x - 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)}}}\]
    3. Using strategy rm
    4. Applied flip--55.4

      \[\leadsto \frac{\color{blue}{\frac{x \cdot x - 2 \cdot 2}{x + 2}}}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)}}\]
    5. Applied associate-/l/55.4

      \[\leadsto \color{blue}{\frac{x \cdot x - 2 \cdot 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)} \cdot \left(x + 2\right)}}\]
    6. Taylor expanded around inf 1.3

      \[\leadsto \color{blue}{\left(\frac{y}{{x}^{2}} + 4.16438922227999964 \cdot x\right) - 110.113924298481081}\]
    7. Simplified1.3

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

    if -5.554983803297941e+21 < x < 9.452827926980448e+52

    1. Initial program 0.8

      \[\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999964 + 78.6994924154000017\right) \cdot x + 137.51941641600001\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000014\right) \cdot x + 263.50507472100003\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606000001}\]
    2. Simplified0.6

      \[\leadsto \color{blue}{\frac{x - 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)}}}\]
    3. Using strategy rm
    4. Applied flip--0.6

      \[\leadsto \frac{\color{blue}{\frac{x \cdot x - 2 \cdot 2}{x + 2}}}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)}}\]
    5. Applied associate-/l/0.6

      \[\leadsto \color{blue}{\frac{x \cdot x - 2 \cdot 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)} \cdot \left(x + 2\right)}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -5554983803297941420000 \lor \neg \left(x \le 9.45282792698044778 \cdot 10^{52}\right):\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}} - 110.113924298481081\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot x - 2 \cdot 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)} \cdot \left(x + 2\right)}\\ \end{array}\]

Reproduce

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