Average Error: 29.9 → 0.8
Time: 1.1min
Precision: binary64
\[x + \frac{y \cdot \left(\left(\left(\left(z \cdot 3.13060547623 + 11.1667541262\right) \cdot z + t\right) \cdot z + a\right) \cdot z + b\right)}{\left(\left(\left(z + 15.234687407\right) \cdot z + 31.4690115749\right) \cdot z + 11.9400905721\right) \cdot z + 0.607771387771} \]
\[\begin{array}{l} \mathbf{if}\;z \leq -7.098557331125062 \cdot 10^{+74} \lor \neg \left(z \leq 1272846294210735.5\right):\\ \;\;\;\;\mathsf{fma}\left(y, \left(3.13060547623 + \left(\frac{t}{{z}^{2}} + \left(457.9610022158428 \cdot \frac{1}{{z}^{2}} + \frac{a}{{z}^{3}}\right)\right)\right) - \left(15.234687407 \cdot \frac{t}{{z}^{3}} + \left(5864.8025282699045 \cdot \frac{1}{{z}^{3}} + 36.52704169880642 \cdot \frac{1}{z}\right)\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_1 := {z}^{3} \cdot \left(z + 15.234687407\right)\\ t_2 := 0.607771387771 + \left(t_1 + z \cdot \left(11.9400905721 + z \cdot 31.4690115749\right)\right)\\ \mathsf{fma}\left(y, \frac{b}{t_2} + \left(t \cdot \left(z \cdot \frac{z}{0.607771387771 + \mathsf{fma}\left(z, \mathsf{fma}\left(z, 31.4690115749, 11.9400905721\right), t_1\right)}\right) + \mathsf{fma}\left(11.1667541262, \frac{{z}^{3}}{t_2}, \mathsf{fma}\left(3.13060547623, \frac{{z}^{4}}{t_2}, \frac{z \cdot a}{t_2}\right)\right)\right), x\right) \end{array}\\ \end{array} \]
x + \frac{y \cdot \left(\left(\left(\left(z \cdot 3.13060547623 + 11.1667541262\right) \cdot z + t\right) \cdot z + a\right) \cdot z + b\right)}{\left(\left(\left(z + 15.234687407\right) \cdot z + 31.4690115749\right) \cdot z + 11.9400905721\right) \cdot z + 0.607771387771}
\begin{array}{l}
\mathbf{if}\;z \leq -7.098557331125062 \cdot 10^{+74} \lor \neg \left(z \leq 1272846294210735.5\right):\\
\;\;\;\;\mathsf{fma}\left(y, \left(3.13060547623 + \left(\frac{t}{{z}^{2}} + \left(457.9610022158428 \cdot \frac{1}{{z}^{2}} + \frac{a}{{z}^{3}}\right)\right)\right) - \left(15.234687407 \cdot \frac{t}{{z}^{3}} + \left(5864.8025282699045 \cdot \frac{1}{{z}^{3}} + 36.52704169880642 \cdot \frac{1}{z}\right)\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_1 := {z}^{3} \cdot \left(z + 15.234687407\right)\\
t_2 := 0.607771387771 + \left(t_1 + z \cdot \left(11.9400905721 + z \cdot 31.4690115749\right)\right)\\
\mathsf{fma}\left(y, \frac{b}{t_2} + \left(t \cdot \left(z \cdot \frac{z}{0.607771387771 + \mathsf{fma}\left(z, \mathsf{fma}\left(z, 31.4690115749, 11.9400905721\right), t_1\right)}\right) + \mathsf{fma}\left(11.1667541262, \frac{{z}^{3}}{t_2}, \mathsf{fma}\left(3.13060547623, \frac{{z}^{4}}{t_2}, \frac{z \cdot a}{t_2}\right)\right)\right), x\right)
\end{array}\\


\end{array}
(FPCore (x y z t a b)
 :precision binary64
 (+
  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))))
(FPCore (x y z t a b)
 :precision binary64
 (if (or (<= z -7.098557331125062e+74) (not (<= z 1272846294210735.5)))
   (fma
    y
    (-
     (+
      3.13060547623
      (+
       (/ t (pow z 2.0))
       (+ (* 457.9610022158428 (/ 1.0 (pow z 2.0))) (/ a (pow z 3.0)))))
     (+
      (* 15.234687407 (/ t (pow z 3.0)))
      (+
       (* 5864.8025282699045 (/ 1.0 (pow z 3.0)))
       (* 36.52704169880642 (/ 1.0 z)))))
    x)
   (let* ((t_1 (* (pow z 3.0) (+ z 15.234687407)))
          (t_2
           (+
            0.607771387771
            (+ t_1 (* z (+ 11.9400905721 (* z 31.4690115749)))))))
     (fma
      y
      (+
       (/ b t_2)
       (+
        (*
         t
         (*
          z
          (/
           z
           (+
            0.607771387771
            (fma z (fma z 31.4690115749 11.9400905721) t_1)))))
        (fma
         11.1667541262
         (/ (pow z 3.0) t_2)
         (fma 3.13060547623 (/ (pow z 4.0) t_2) (/ (* z a) t_2)))))
      x))))
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 tmp;
	if ((z <= -7.098557331125062e+74) || !(z <= 1272846294210735.5)) {
		tmp = fma(y, ((3.13060547623 + ((t / pow(z, 2.0)) + ((457.9610022158428 * (1.0 / pow(z, 2.0))) + (a / pow(z, 3.0))))) - ((15.234687407 * (t / pow(z, 3.0))) + ((5864.8025282699045 * (1.0 / pow(z, 3.0))) + (36.52704169880642 * (1.0 / z))))), x);
	} else {
		double t_1 = pow(z, 3.0) * (z + 15.234687407);
		double t_2 = 0.607771387771 + (t_1 + (z * (11.9400905721 + (z * 31.4690115749))));
		tmp = fma(y, ((b / t_2) + ((t * (z * (z / (0.607771387771 + fma(z, fma(z, 31.4690115749, 11.9400905721), t_1))))) + fma(11.1667541262, (pow(z, 3.0) / t_2), fma(3.13060547623, (pow(z, 4.0) / t_2), ((z * a) / t_2))))), x);
	}
	return tmp;
}

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

Target

Original29.9
Target1.3
Herbie0.8
\[\begin{array}{l} \mathbf{if}\;z < -6.499344996252632 \cdot 10^{+53}:\\ \;\;\;\;x + \left(\left(3.13060547623 - \frac{36.527041698806414}{z}\right) + \frac{t}{z \cdot z}\right) \cdot \frac{y}{1}\\ \mathbf{elif}\;z < 7.066965436914287 \cdot 10^{+59}:\\ \;\;\;\;x + \frac{y}{\frac{\left(\left(\left(z + 15.234687407\right) \cdot z + 31.4690115749\right) \cdot z + 11.9400905721\right) \cdot z + 0.607771387771}{\left(\left(\left(z \cdot 3.13060547623 + 11.1667541262\right) \cdot z + t\right) \cdot z + a\right) \cdot z + b}}\\ \mathbf{else}:\\ \;\;\;\;x + \left(\left(3.13060547623 - \frac{36.527041698806414}{z}\right) + \frac{t}{z \cdot z}\right) \cdot \frac{y}{1}\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. if z < -7.0985573311250624e74 or 1272846294210735.5 < z

    1. Initial program 60.0

      \[x + \frac{y \cdot \left(\left(\left(\left(z \cdot 3.13060547623 + 11.1667541262\right) \cdot z + t\right) \cdot z + a\right) \cdot z + b\right)}{\left(\left(\left(z + 15.234687407\right) \cdot z + 31.4690115749\right) \cdot z + 11.9400905721\right) \cdot z + 0.607771387771} \]
    2. Simplified58.4

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{\mathsf{fma}\left(z, \mathsf{fma}\left(z, \mathsf{fma}\left(z, \mathsf{fma}\left(z, 3.13060547623, 11.1667541262\right), t\right), a\right), b\right)}{\mathsf{fma}\left(z, \mathsf{fma}\left(z, \mathsf{fma}\left(z, z + 15.234687407, 31.4690115749\right), 11.9400905721\right), 0.607771387771\right)}, x\right)} \]
    3. Taylor expanded in z around inf 0.6

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\left(3.13060547623 + \left(\frac{t}{{z}^{2}} + \left(457.9610022158428 \cdot \frac{1}{{z}^{2}} + \frac{a}{{z}^{3}}\right)\right)\right) - \left(15.234687407 \cdot \frac{t}{{z}^{3}} + \left(5864.8025282699045 \cdot \frac{1}{{z}^{3}} + 36.52704169880642 \cdot \frac{1}{z}\right)\right)}, x\right) \]

    if -7.0985573311250624e74 < z < 1272846294210735.5

    1. Initial program 3.1

      \[x + \frac{y \cdot \left(\left(\left(\left(z \cdot 3.13060547623 + 11.1667541262\right) \cdot z + t\right) \cdot z + a\right) \cdot z + b\right)}{\left(\left(\left(z + 15.234687407\right) \cdot z + 31.4690115749\right) \cdot z + 11.9400905721\right) \cdot z + 0.607771387771} \]
    2. Simplified1.4

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{\mathsf{fma}\left(z, \mathsf{fma}\left(z, \mathsf{fma}\left(z, \mathsf{fma}\left(z, 3.13060547623, 11.1667541262\right), t\right), a\right), b\right)}{\mathsf{fma}\left(z, \mathsf{fma}\left(z, \mathsf{fma}\left(z, z + 15.234687407, 31.4690115749\right), 11.9400905721\right), 0.607771387771\right)}, x\right)} \]
    3. Taylor expanded in t around 0 1.7

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\frac{b}{0.607771387771 + \left(31.4690115749 \cdot {z}^{2} + \left({z}^{4} + \left(15.234687407 \cdot {z}^{3} + 11.9400905721 \cdot z\right)\right)\right)} + \left(\frac{t \cdot {z}^{2}}{0.607771387771 + \left(31.4690115749 \cdot {z}^{2} + \left({z}^{4} + \left(15.234687407 \cdot {z}^{3} + 11.9400905721 \cdot z\right)\right)\right)} + \left(11.1667541262 \cdot \frac{{z}^{3}}{0.607771387771 + \left(31.4690115749 \cdot {z}^{2} + \left({z}^{4} + \left(15.234687407 \cdot {z}^{3} + 11.9400905721 \cdot z\right)\right)\right)} + \left(\frac{a \cdot z}{0.607771387771 + \left(31.4690115749 \cdot {z}^{2} + \left({z}^{4} + \left(15.234687407 \cdot {z}^{3} + 11.9400905721 \cdot z\right)\right)\right)} + 3.13060547623 \cdot \frac{{z}^{4}}{0.607771387771 + \left(31.4690115749 \cdot {z}^{2} + \left({z}^{4} + \left(15.234687407 \cdot {z}^{3} + 11.9400905721 \cdot z\right)\right)\right)}\right)\right)\right)}, x\right) \]
    4. Simplified1.7

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\frac{b}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)} + \left(\frac{t \cdot \left(z \cdot z\right)}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)} + \mathsf{fma}\left(11.1667541262, \frac{{z}^{3}}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)}, \mathsf{fma}\left(3.13060547623, \frac{{z}^{4}}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)}, \frac{a \cdot z}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)}\right)\right)\right)}, x\right) \]
    5. Applied *-un-lft-identity_binary641.7

      \[\leadsto \mathsf{fma}\left(y, \frac{b}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)} + \left(\frac{t \cdot \left(z \cdot z\right)}{\color{blue}{1 \cdot \left(0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)\right)}} + \mathsf{fma}\left(11.1667541262, \frac{{z}^{3}}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)}, \mathsf{fma}\left(3.13060547623, \frac{{z}^{4}}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)}, \frac{a \cdot z}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)}\right)\right)\right), x\right) \]
    6. Applied times-frac_binary640.9

      \[\leadsto \mathsf{fma}\left(y, \frac{b}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)} + \left(\color{blue}{\frac{t}{1} \cdot \frac{z \cdot z}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)}} + \mathsf{fma}\left(11.1667541262, \frac{{z}^{3}}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)}, \mathsf{fma}\left(3.13060547623, \frac{{z}^{4}}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)}, \frac{a \cdot z}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)}\right)\right)\right), x\right) \]
    7. Simplified0.9

      \[\leadsto \mathsf{fma}\left(y, \frac{b}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)} + \left(\color{blue}{t} \cdot \frac{z \cdot z}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)} + \mathsf{fma}\left(11.1667541262, \frac{{z}^{3}}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)}, \mathsf{fma}\left(3.13060547623, \frac{{z}^{4}}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)}, \frac{a \cdot z}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)}\right)\right)\right), x\right) \]
    8. Simplified0.9

      \[\leadsto \mathsf{fma}\left(y, \frac{b}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)} + \left(t \cdot \color{blue}{\left(\frac{z}{0.607771387771 + \mathsf{fma}\left(z, \mathsf{fma}\left(z, 31.4690115749, 11.9400905721\right), {z}^{3} \cdot \left(z + 15.234687407\right)\right)} \cdot z\right)} + \mathsf{fma}\left(11.1667541262, \frac{{z}^{3}}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)}, \mathsf{fma}\left(3.13060547623, \frac{{z}^{4}}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)}, \frac{a \cdot z}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + 31.4690115749 \cdot z\right)\right)}\right)\right)\right), x\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.098557331125062 \cdot 10^{+74} \lor \neg \left(z \leq 1272846294210735.5\right):\\ \;\;\;\;\mathsf{fma}\left(y, \left(3.13060547623 + \left(\frac{t}{{z}^{2}} + \left(457.9610022158428 \cdot \frac{1}{{z}^{2}} + \frac{a}{{z}^{3}}\right)\right)\right) - \left(15.234687407 \cdot \frac{t}{{z}^{3}} + \left(5864.8025282699045 \cdot \frac{1}{{z}^{3}} + 36.52704169880642 \cdot \frac{1}{z}\right)\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{b}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + z \cdot 31.4690115749\right)\right)} + \left(t \cdot \left(z \cdot \frac{z}{0.607771387771 + \mathsf{fma}\left(z, \mathsf{fma}\left(z, 31.4690115749, 11.9400905721\right), {z}^{3} \cdot \left(z + 15.234687407\right)\right)}\right) + \mathsf{fma}\left(11.1667541262, \frac{{z}^{3}}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + z \cdot 31.4690115749\right)\right)}, \mathsf{fma}\left(3.13060547623, \frac{{z}^{4}}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + z \cdot 31.4690115749\right)\right)}, \frac{z \cdot a}{0.607771387771 + \left({z}^{3} \cdot \left(z + 15.234687407\right) + z \cdot \left(11.9400905721 + z \cdot 31.4690115749\right)\right)}\right)\right)\right), x\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2021280 
(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.0))) (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.0)))))

  (+ 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))))