Average Error: 27.1 → 0.5
Time: 9.2s
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 -4.26409396866929665 \cdot 10^{68} \lor \neg \left(x \le 1.32155597286449126 \cdot 10^{55}\right):\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}} - 110.11392429848109\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 -4.26409396866929665 \cdot 10^{68} \lor \neg \left(x \le 1.32155597286449126 \cdot 10^{55}\right):\\
\;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}} - 110.11392429848109\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 r444827 = x;
        double r444828 = 2.0;
        double r444829 = r444827 - r444828;
        double r444830 = 4.16438922228;
        double r444831 = r444827 * r444830;
        double r444832 = 78.6994924154;
        double r444833 = r444831 + r444832;
        double r444834 = r444833 * r444827;
        double r444835 = 137.519416416;
        double r444836 = r444834 + r444835;
        double r444837 = r444836 * r444827;
        double r444838 = y;
        double r444839 = r444837 + r444838;
        double r444840 = r444839 * r444827;
        double r444841 = z;
        double r444842 = r444840 + r444841;
        double r444843 = r444829 * r444842;
        double r444844 = 43.3400022514;
        double r444845 = r444827 + r444844;
        double r444846 = r444845 * r444827;
        double r444847 = 263.505074721;
        double r444848 = r444846 + r444847;
        double r444849 = r444848 * r444827;
        double r444850 = 313.399215894;
        double r444851 = r444849 + r444850;
        double r444852 = r444851 * r444827;
        double r444853 = 47.066876606;
        double r444854 = r444852 + r444853;
        double r444855 = r444843 / r444854;
        return r444855;
}

double f(double x, double y, double z) {
        double r444856 = x;
        double r444857 = -4.2640939686692966e+68;
        bool r444858 = r444856 <= r444857;
        double r444859 = 1.3215559728644913e+55;
        bool r444860 = r444856 <= r444859;
        double r444861 = !r444860;
        bool r444862 = r444858 || r444861;
        double r444863 = 4.16438922228;
        double r444864 = y;
        double r444865 = 2.0;
        double r444866 = pow(r444856, r444865);
        double r444867 = r444864 / r444866;
        double r444868 = 110.1139242984811;
        double r444869 = r444867 - r444868;
        double r444870 = fma(r444856, r444863, r444869);
        double r444871 = r444856 * r444856;
        double r444872 = 2.0;
        double r444873 = r444872 * r444872;
        double r444874 = r444871 - r444873;
        double r444875 = 43.3400022514;
        double r444876 = r444856 + r444875;
        double r444877 = 263.505074721;
        double r444878 = fma(r444876, r444856, r444877);
        double r444879 = 313.399215894;
        double r444880 = fma(r444878, r444856, r444879);
        double r444881 = 47.066876606;
        double r444882 = fma(r444880, r444856, r444881);
        double r444883 = 78.6994924154;
        double r444884 = fma(r444856, r444863, r444883);
        double r444885 = 137.519416416;
        double r444886 = fma(r444884, r444856, r444885);
        double r444887 = fma(r444886, r444856, r444864);
        double r444888 = z;
        double r444889 = fma(r444887, r444856, r444888);
        double r444890 = r444882 / r444889;
        double r444891 = r444856 + r444872;
        double r444892 = r444890 * r444891;
        double r444893 = r444874 / r444892;
        double r444894 = r444862 ? r444870 : r444893;
        return r444894;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original27.1
Target0.4
Herbie0.5
\[\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 < -4.2640939686692966e+68 or 1.3215559728644913e+55 < x

    1. Initial program 63.6

      \[\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. Simplified60.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. Taylor expanded around inf 0.3

      \[\leadsto \color{blue}{\left(\frac{y}{{x}^{2}} + 4.16438922227999964 \cdot x\right) - 110.11392429848109}\]
    4. Simplified0.3

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

    if -4.2640939686692966e+68 < x < 1.3215559728644913e+55

    1. Initial program 2.1

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -4.26409396866929665 \cdot 10^{68} \lor \neg \left(x \le 1.32155597286449126 \cdot 10^{55}\right):\\ \;\;\;\;\mathsf{fma}\left(x, 4.16438922227999964, \frac{y}{{x}^{2}} - 110.11392429848109\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 2020060 +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)))