Average Error: 29.4 → 1.2
Time: 6.3s
Precision: 64
\[x + \frac{y \cdot \left(\left(\left(\left(z \cdot 3.13060547622999996 + 11.166754126200001\right) \cdot z + t\right) \cdot z + a\right) \cdot z + b\right)}{\left(\left(\left(z + 15.234687406999999\right) \cdot z + 31.469011574900001\right) \cdot z + 11.940090572100001\right) \cdot z + 0.60777138777100004}\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.0056051312042543 \cdot 10^{25}:\\ \;\;\;\;\mathsf{fma}\left(y, 3.13060547622999996 + \frac{1}{\left|z\right|} \cdot \frac{t}{\left|z\right|}, x\right)\\ \mathbf{elif}\;z \le 1.0256103088739618 \cdot 10^{24}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(z + 15.234687406999999, z, 31.469011574900001\right), z, 11.940090572100001\right), z, 0.60777138777100004\right)}{y}}, \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(z, 3.13060547622999996, 11.166754126200001\right), z, t\right), z, a\right), z, b\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, 3.13060547622999996 + \frac{1}{\frac{{z}^{2}}{t}}, x\right)\\ \end{array}\]
x + \frac{y \cdot \left(\left(\left(\left(z \cdot 3.13060547622999996 + 11.166754126200001\right) \cdot z + t\right) \cdot z + a\right) \cdot z + b\right)}{\left(\left(\left(z + 15.234687406999999\right) \cdot z + 31.469011574900001\right) \cdot z + 11.940090572100001\right) \cdot z + 0.60777138777100004}
\begin{array}{l}
\mathbf{if}\;z \le -3.0056051312042543 \cdot 10^{25}:\\
\;\;\;\;\mathsf{fma}\left(y, 3.13060547622999996 + \frac{1}{\left|z\right|} \cdot \frac{t}{\left|z\right|}, x\right)\\

\mathbf{elif}\;z \le 1.0256103088739618 \cdot 10^{24}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(z + 15.234687406999999, z, 31.469011574900001\right), z, 11.940090572100001\right), z, 0.60777138777100004\right)}{y}}, \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(z, 3.13060547622999996, 11.166754126200001\right), z, t\right), z, a\right), z, b\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, 3.13060547622999996 + \frac{1}{\frac{{z}^{2}}{t}}, x\right)\\

\end{array}
double code(double x, double y, double z, double t, double a, double b) {
	return (x + ((y * ((((((((z * 3.13060547623) + 11.1667541262) * z) + t) * z) + a) * z) + b)) / (((((((z + 15.234687407) * z) + 31.4690115749) * z) + 11.9400905721) * z) + 0.607771387771)));
}
double code(double x, double y, double z, double t, double a, double b) {
	double temp;
	if ((z <= -3.0056051312042543e+25)) {
		temp = fma(y, (3.13060547623 + ((1.0 / fabs(z)) * (t / fabs(z)))), x);
	} else {
		double temp_1;
		if ((z <= 1.0256103088739618e+24)) {
			temp_1 = fma((1.0 / (fma(fma(fma((z + 15.234687407), z, 31.4690115749), z, 11.9400905721), z, 0.607771387771) / y)), fma(fma(fma(fma(z, 3.13060547623, 11.1667541262), z, t), z, a), z, b), x);
		} else {
			temp_1 = fma(y, (3.13060547623 + (1.0 / (pow(z, 2.0) / t))), x);
		}
		temp = temp_1;
	}
	return temp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Bits error versus b

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original29.4
Target1.0
Herbie1.2
\[\begin{array}{l} \mathbf{if}\;z \lt -6.4993449962526318 \cdot 10^{53}:\\ \;\;\;\;x + \left(\left(3.13060547622999996 - \frac{36.527041698806414}{z}\right) + \frac{t}{z \cdot z}\right) \cdot \frac{y}{1}\\ \mathbf{elif}\;z \lt 7.0669654369142868 \cdot 10^{59}:\\ \;\;\;\;x + \frac{y}{\frac{\left(\left(\left(z + 15.234687406999999\right) \cdot z + 31.469011574900001\right) \cdot z + 11.940090572100001\right) \cdot z + 0.60777138777100004}{\left(\left(\left(z \cdot 3.13060547622999996 + 11.166754126200001\right) \cdot z + t\right) \cdot z + a\right) \cdot z + b}}\\ \mathbf{else}:\\ \;\;\;\;x + \left(\left(3.13060547622999996 - \frac{36.527041698806414}{z}\right) + \frac{t}{z \cdot z}\right) \cdot \frac{y}{1}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if z < -3.0056051312042543e+25

    1. Initial program 58.0

      \[x + \frac{y \cdot \left(\left(\left(\left(z \cdot 3.13060547622999996 + 11.166754126200001\right) \cdot z + t\right) \cdot z + a\right) \cdot z + b\right)}{\left(\left(\left(z + 15.234687406999999\right) \cdot z + 31.469011574900001\right) \cdot z + 11.940090572100001\right) \cdot z + 0.60777138777100004}\]
    2. Simplified56.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(z + 15.234687406999999, z, 31.469011574900001\right), z, 11.940090572100001\right), z, 0.60777138777100004\right)}, \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(z, 3.13060547622999996, 11.166754126200001\right), z, t\right), z, a\right), z, b\right), x\right)}\]
    3. Taylor expanded around inf 8.9

      \[\leadsto \color{blue}{x + \left(\frac{t \cdot y}{{z}^{2}} + 3.13060547622999996 \cdot y\right)}\]
    4. Simplified1.8

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, 3.13060547622999996 + \frac{t}{{z}^{2}}, x\right)}\]
    5. Using strategy rm
    6. Applied add-sqr-sqrt1.8

      \[\leadsto \mathsf{fma}\left(y, 3.13060547622999996 + \frac{t}{\color{blue}{\sqrt{{z}^{2}} \cdot \sqrt{{z}^{2}}}}, x\right)\]
    7. Applied *-un-lft-identity1.8

      \[\leadsto \mathsf{fma}\left(y, 3.13060547622999996 + \frac{\color{blue}{1 \cdot t}}{\sqrt{{z}^{2}} \cdot \sqrt{{z}^{2}}}, x\right)\]
    8. Applied times-frac1.8

      \[\leadsto \mathsf{fma}\left(y, 3.13060547622999996 + \color{blue}{\frac{1}{\sqrt{{z}^{2}}} \cdot \frac{t}{\sqrt{{z}^{2}}}}, x\right)\]
    9. Simplified1.8

      \[\leadsto \mathsf{fma}\left(y, 3.13060547622999996 + \color{blue}{\frac{1}{\left|z\right|}} \cdot \frac{t}{\sqrt{{z}^{2}}}, x\right)\]
    10. Simplified1.8

      \[\leadsto \mathsf{fma}\left(y, 3.13060547622999996 + \frac{1}{\left|z\right|} \cdot \color{blue}{\frac{t}{\left|z\right|}}, x\right)\]

    if -3.0056051312042543e+25 < z < 1.0256103088739618e+24

    1. Initial program 0.9

      \[x + \frac{y \cdot \left(\left(\left(\left(z \cdot 3.13060547622999996 + 11.166754126200001\right) \cdot z + t\right) \cdot z + a\right) \cdot z + b\right)}{\left(\left(\left(z + 15.234687406999999\right) \cdot z + 31.469011574900001\right) \cdot z + 11.940090572100001\right) \cdot z + 0.60777138777100004}\]
    2. Simplified0.5

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(z + 15.234687406999999, z, 31.469011574900001\right), z, 11.940090572100001\right), z, 0.60777138777100004\right)}, \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(z, 3.13060547622999996, 11.166754126200001\right), z, t\right), z, a\right), z, b\right), x\right)}\]
    3. Using strategy rm
    4. Applied clear-num0.5

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(z + 15.234687406999999, z, 31.469011574900001\right), z, 11.940090572100001\right), z, 0.60777138777100004\right)}{y}}}, \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(z, 3.13060547622999996, 11.166754126200001\right), z, t\right), z, a\right), z, b\right), x\right)\]

    if 1.0256103088739618e+24 < z

    1. Initial program 58.2

      \[x + \frac{y \cdot \left(\left(\left(\left(z \cdot 3.13060547622999996 + 11.166754126200001\right) \cdot z + t\right) \cdot z + a\right) \cdot z + b\right)}{\left(\left(\left(z + 15.234687406999999\right) \cdot z + 31.469011574900001\right) \cdot z + 11.940090572100001\right) \cdot z + 0.60777138777100004}\]
    2. Simplified56.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(z + 15.234687406999999, z, 31.469011574900001\right), z, 11.940090572100001\right), z, 0.60777138777100004\right)}, \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(z, 3.13060547622999996, 11.166754126200001\right), z, t\right), z, a\right), z, b\right), x\right)}\]
    3. Taylor expanded around inf 9.0

      \[\leadsto \color{blue}{x + \left(\frac{t \cdot y}{{z}^{2}} + 3.13060547622999996 \cdot y\right)}\]
    4. Simplified2.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, 3.13060547622999996 + \frac{t}{{z}^{2}}, x\right)}\]
    5. Using strategy rm
    6. Applied clear-num2.0

      \[\leadsto \mathsf{fma}\left(y, 3.13060547622999996 + \color{blue}{\frac{1}{\frac{{z}^{2}}{t}}}, x\right)\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -3.0056051312042543 \cdot 10^{25}:\\ \;\;\;\;\mathsf{fma}\left(y, 3.13060547622999996 + \frac{1}{\left|z\right|} \cdot \frac{t}{\left|z\right|}, x\right)\\ \mathbf{elif}\;z \le 1.0256103088739618 \cdot 10^{24}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(z + 15.234687406999999, z, 31.469011574900001\right), z, 11.940090572100001\right), z, 0.60777138777100004\right)}{y}}, \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(z, 3.13060547622999996, 11.166754126200001\right), z, t\right), z, a\right), z, b\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, 3.13060547622999996 + \frac{1}{\frac{{z}^{2}}{t}}, x\right)\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< z -6.499344996252632e+53) (+ x (* (+ (- 3.13060547623 (/ 36.527041698806414 z)) (/ t (* z z))) (/ y 1))) (if (< z 7.066965436914287e+59) (+ x (/ y (/ (+ (* (+ (* (+ (* (+ z 15.234687407) z) 31.4690115749) z) 11.9400905721) z) 0.607771387771) (+ (* (+ (* (+ (* (+ (* z 3.13060547623) 11.1667541262) z) t) z) a) z) b)))) (+ x (* (+ (- 3.13060547623 (/ 36.527041698806414 z)) (/ t (* z z))) (/ y 1)))))

  (+ x (/ (* y (+ (* (+ (* (+ (* (+ (* z 3.13060547623) 11.1667541262) z) t) z) a) z) b)) (+ (* (+ (* (+ (* (+ z 15.234687407) z) 31.4690115749) z) 11.9400905721) z) 0.607771387771))))