Average Error: 29.0 → 1.2
Time: 5.4s
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 -9.1364780761282189 \cdot 10^{32}:\\ \;\;\;\;\mathsf{fma}\left(y, 3.13060547622999996 + \frac{1}{z} \cdot \frac{t}{z}, x\right)\\ \mathbf{elif}\;z \le 1.54616507477103977 \cdot 10^{25}:\\ \;\;\;\;\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)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, 3.13060547622999996 + \frac{\frac{t}{z}}{z}, 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 -9.1364780761282189 \cdot 10^{32}:\\
\;\;\;\;\mathsf{fma}\left(y, 3.13060547622999996 + \frac{1}{z} \cdot \frac{t}{z}, x\right)\\

\mathbf{elif}\;z \le 1.54616507477103977 \cdot 10^{25}:\\
\;\;\;\;\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)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, 3.13060547622999996 + \frac{\frac{t}{z}}{z}, 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 <= -9.136478076128219e+32)) {
		temp = fma(y, (3.13060547623 + ((1.0 / z) * (t / z))), x);
	} else {
		double temp_1;
		if ((z <= 1.5461650747710398e+25)) {
			temp_1 = fma((y / fma(fma(fma((z + 15.234687407), z, 31.4690115749), z, 11.9400905721), z, 0.607771387771)), fma(fma(fma(fma(z, 3.13060547623, 11.1667541262), z, t), z, a), z, b), x);
		} else {
			temp_1 = fma(y, (3.13060547623 + ((t / z) / z)), 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.0
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 < -9.136478076128219e+32

    1. Initial program 59.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.9

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

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

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

      \[\leadsto \mathsf{fma}\left(y, 3.13060547622999996 + \frac{t}{{\color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)}}^{2}}, x\right)\]
    7. Applied unpow-prod-down64.0

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

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

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

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

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

    if -9.136478076128219e+32 < z < 1.5461650747710398e+25

    1. Initial program 0.8

      \[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)}\]

    if 1.5461650747710398e+25 < z

    1. Initial program 58.1

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, 3.13060547622999996 + \frac{t}{\color{blue}{z \cdot z}}, x\right)\]
    7. Applied associate-/r*2.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -9.1364780761282189 \cdot 10^{32}:\\ \;\;\;\;\mathsf{fma}\left(y, 3.13060547622999996 + \frac{1}{z} \cdot \frac{t}{z}, x\right)\\ \mathbf{elif}\;z \le 1.54616507477103977 \cdot 10^{25}:\\ \;\;\;\;\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)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, 3.13060547622999996 + \frac{\frac{t}{z}}{z}, x\right)\\ \end{array}\]

Reproduce

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