Average Error: 29.7 → 0.8
Time: 23.4s
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} t_1 := \sqrt{\mathsf{fma}\left(z, \mathsf{fma}\left(z, \mathsf{fma}\left(z, z + 15.234687407, 31.4690115749\right), 11.9400905721\right), 0.607771387771\right)}\\ t_2 := \frac{y \cdot \left(z \cdot \left(z \cdot \left(z \cdot \left(z \cdot 3.13060547623 + 11.1667541262\right) + t\right) + a\right) + b\right)}{z \cdot \left(z \cdot \left(z \cdot \left(z + 15.234687407\right) + 31.4690115749\right) + 11.9400905721\right) + 0.607771387771}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{\left(138.15549227701462 + \left(\mathsf{fma}\left(z \cdot z, 3.13060547623, t\right) + \frac{a}{z}\right)\right) - \mathsf{fma}\left(7.6173437035, \frac{t}{z}, \mathsf{fma}\left(z, 12.68014378630321, \frac{1556.0539424356678}{z}\right)\right)}{t_1}, x\right)\\ \mathbf{elif}\;t_2 \leq 1.78346345221931 \cdot 10^{+287}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{\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)}{t_1}}{t_1}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\frac{y}{z \cdot z} \cdot \left(\frac{a}{z} + 457.9610022158428\right) + \mathsf{fma}\left(3.13060547623, y, x\right)\right) + \frac{y}{z} \cdot \left(\frac{t}{z} - \frac{5864.8025282699045}{z \cdot z}\right)\right) - \mathsf{fma}\left(36.52704169880642, \frac{y}{z}, 15.234687407 \cdot \left(t \cdot \frac{y}{{z}^{3}}\right)\right)\\ \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}
t_1 := \sqrt{\mathsf{fma}\left(z, \mathsf{fma}\left(z, \mathsf{fma}\left(z, z + 15.234687407, 31.4690115749\right), 11.9400905721\right), 0.607771387771\right)}\\
t_2 := \frac{y \cdot \left(z \cdot \left(z \cdot \left(z \cdot \left(z \cdot 3.13060547623 + 11.1667541262\right) + t\right) + a\right) + b\right)}{z \cdot \left(z \cdot \left(z \cdot \left(z + 15.234687407\right) + 31.4690115749\right) + 11.9400905721\right) + 0.607771387771}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{\left(138.15549227701462 + \left(\mathsf{fma}\left(z \cdot z, 3.13060547623, t\right) + \frac{a}{z}\right)\right) - \mathsf{fma}\left(7.6173437035, \frac{t}{z}, \mathsf{fma}\left(z, 12.68014378630321, \frac{1556.0539424356678}{z}\right)\right)}{t_1}, x\right)\\

\mathbf{elif}\;t_2 \leq 1.78346345221931 \cdot 10^{+287}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{\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)}{t_1}}{t_1}, x\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\left(\frac{y}{z \cdot z} \cdot \left(\frac{a}{z} + 457.9610022158428\right) + \mathsf{fma}\left(3.13060547623, y, x\right)\right) + \frac{y}{z} \cdot \left(\frac{t}{z} - \frac{5864.8025282699045}{z \cdot z}\right)\right) - \mathsf{fma}\left(36.52704169880642, \frac{y}{z}, 15.234687407 \cdot \left(t \cdot \frac{y}{{z}^{3}}\right)\right)\\


\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
 (let* ((t_1
         (sqrt
          (fma
           z
           (fma z (fma z (+ z 15.234687407) 31.4690115749) 11.9400905721)
           0.607771387771)))
        (t_2
         (/
          (*
           y
           (+
            (* z (+ (* z (+ (* z (+ (* z 3.13060547623) 11.1667541262)) t)) a))
            b))
          (+
           (*
            z
            (+ (* z (+ (* z (+ z 15.234687407)) 31.4690115749)) 11.9400905721))
           0.607771387771))))
   (if (<= t_2 (- INFINITY))
     (fma
      y
      (/
       (-
        (+ 138.15549227701462 (+ (fma (* z z) 3.13060547623 t) (/ a z)))
        (fma
         7.6173437035
         (/ t z)
         (fma z 12.68014378630321 (/ 1556.0539424356678 z))))
       t_1)
      x)
     (if (<= t_2 1.78346345221931e+287)
       (fma
        y
        (/
         (/
          (fma z (fma z (fma z (fma z 3.13060547623 11.1667541262) t) a) b)
          t_1)
         t_1)
        x)
       (-
        (+
         (+
          (* (/ y (* z z)) (+ (/ a z) 457.9610022158428))
          (fma 3.13060547623 y x))
         (* (/ y z) (- (/ t z) (/ 5864.8025282699045 (* z z)))))
        (fma
         36.52704169880642
         (/ y z)
         (* 15.234687407 (* t (/ y (pow z 3.0))))))))))
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 t_1 = sqrt(fma(z, fma(z, fma(z, (z + 15.234687407), 31.4690115749), 11.9400905721), 0.607771387771));
	double t_2 = (y * ((z * ((z * ((z * ((z * 3.13060547623) + 11.1667541262)) + t)) + a)) + b)) / ((z * ((z * ((z * (z + 15.234687407)) + 31.4690115749)) + 11.9400905721)) + 0.607771387771);
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = fma(y, (((138.15549227701462 + (fma((z * z), 3.13060547623, t) + (a / z))) - fma(7.6173437035, (t / z), fma(z, 12.68014378630321, (1556.0539424356678 / z)))) / t_1), x);
	} else if (t_2 <= 1.78346345221931e+287) {
		tmp = fma(y, ((fma(z, fma(z, fma(z, fma(z, 3.13060547623, 11.1667541262), t), a), b) / t_1) / t_1), x);
	} else {
		tmp = ((((y / (z * z)) * ((a / z) + 457.9610022158428)) + fma(3.13060547623, y, x)) + ((y / z) * ((t / z) - (5864.8025282699045 / (z * z))))) - fma(36.52704169880642, (y / z), (15.234687407 * (t * (y / pow(z, 3.0)))));
	}
	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.7
Target1.1
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 3 regimes
  2. if (/.f64 (*.f64 y (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 z 313060547623/100000000000) 55833770631/5000000000) z) t) z) a) z) b)) (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 z 15234687407/1000000000) z) 314690115749/10000000000) z) 119400905721/10000000000) z) 607771387771/1000000000000)) < -inf.0

    1. Initial program 64.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. Simplified27.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. Applied add-sqr-sqrt_binary6427.5

      \[\leadsto \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)}{\color{blue}{\sqrt{\mathsf{fma}\left(z, \mathsf{fma}\left(z, \mathsf{fma}\left(z, z + 15.234687407, 31.4690115749\right), 11.9400905721\right), 0.607771387771\right)} \cdot \sqrt{\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) \]
    4. Applied associate-/r*_binary6427.5

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\frac{\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)}{\sqrt{\mathsf{fma}\left(z, \mathsf{fma}\left(z, \mathsf{fma}\left(z, z + 15.234687407, 31.4690115749\right), 11.9400905721\right), 0.607771387771\right)}}}{\sqrt{\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) \]
    5. Taylor expanded in z around inf 6.2

      \[\leadsto \mathsf{fma}\left(y, \frac{\color{blue}{\left(138.15549227701462 + \left(3.13060547623 \cdot {z}^{2} + \left(\frac{a}{z} + t\right)\right)\right) - \left(7.6173437035 \cdot \frac{t}{z} + \left(12.68014378630321 \cdot z + 1556.0539424356678 \cdot \frac{1}{z}\right)\right)}}{\sqrt{\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) \]
    6. Simplified6.2

      \[\leadsto \mathsf{fma}\left(y, \frac{\color{blue}{\left(138.15549227701462 + \left(\mathsf{fma}\left(z \cdot z, 3.13060547623, t\right) + \frac{a}{z}\right)\right) - \mathsf{fma}\left(7.6173437035, \frac{t}{z}, \mathsf{fma}\left(z, 12.68014378630321, \frac{1556.0539424356678}{z}\right)\right)}}{\sqrt{\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) \]

    if -inf.0 < (/.f64 (*.f64 y (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 z 313060547623/100000000000) 55833770631/5000000000) z) t) z) a) z) b)) (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 z 15234687407/1000000000) z) 314690115749/10000000000) z) 119400905721/10000000000) z) 607771387771/1000000000000)) < 1.78346345221931013e287

    1. Initial program 0.2

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

      \[\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. Applied add-sqr-sqrt_binary640.4

      \[\leadsto \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)}{\color{blue}{\sqrt{\mathsf{fma}\left(z, \mathsf{fma}\left(z, \mathsf{fma}\left(z, z + 15.234687407, 31.4690115749\right), 11.9400905721\right), 0.607771387771\right)} \cdot \sqrt{\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) \]
    4. Applied associate-/r*_binary640.3

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\frac{\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)}{\sqrt{\mathsf{fma}\left(z, \mathsf{fma}\left(z, \mathsf{fma}\left(z, z + 15.234687407, 31.4690115749\right), 11.9400905721\right), 0.607771387771\right)}}}{\sqrt{\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) \]

    if 1.78346345221931013e287 < (/.f64 (*.f64 y (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 z 313060547623/100000000000) 55833770631/5000000000) z) t) z) a) z) b)) (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 z 15234687407/1000000000) z) 314690115749/10000000000) z) 119400905721/10000000000) z) 607771387771/1000000000000))

    1. Initial program 63.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. Simplified61.2

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

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

      \[\leadsto \color{blue}{\left(\left(\frac{y}{z \cdot z} \cdot \left(457.9610022158428 + \frac{a}{z}\right) + \mathsf{fma}\left(3.13060547623, y, x\right)\right) + \frac{y}{z} \cdot \left(\frac{t}{z} - \frac{5864.8025282699045}{z \cdot z}\right)\right) - \mathsf{fma}\left(36.52704169880642, \frac{y}{z}, 15.234687407 \cdot \left(\frac{y}{{z}^{3}} \cdot t\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y \cdot \left(z \cdot \left(z \cdot \left(z \cdot \left(z \cdot 3.13060547623 + 11.1667541262\right) + t\right) + a\right) + b\right)}{z \cdot \left(z \cdot \left(z \cdot \left(z + 15.234687407\right) + 31.4690115749\right) + 11.9400905721\right) + 0.607771387771} \leq -\infty:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{\left(138.15549227701462 + \left(\mathsf{fma}\left(z \cdot z, 3.13060547623, t\right) + \frac{a}{z}\right)\right) - \mathsf{fma}\left(7.6173437035, \frac{t}{z}, \mathsf{fma}\left(z, 12.68014378630321, \frac{1556.0539424356678}{z}\right)\right)}{\sqrt{\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)\\ \mathbf{elif}\;\frac{y \cdot \left(z \cdot \left(z \cdot \left(z \cdot \left(z \cdot 3.13060547623 + 11.1667541262\right) + t\right) + a\right) + b\right)}{z \cdot \left(z \cdot \left(z \cdot \left(z + 15.234687407\right) + 31.4690115749\right) + 11.9400905721\right) + 0.607771387771} \leq 1.78346345221931 \cdot 10^{+287}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{\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)}{\sqrt{\mathsf{fma}\left(z, \mathsf{fma}\left(z, \mathsf{fma}\left(z, z + 15.234687407, 31.4690115749\right), 11.9400905721\right), 0.607771387771\right)}}}{\sqrt{\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)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\frac{y}{z \cdot z} \cdot \left(\frac{a}{z} + 457.9610022158428\right) + \mathsf{fma}\left(3.13060547623, y, x\right)\right) + \frac{y}{z} \cdot \left(\frac{t}{z} - \frac{5864.8025282699045}{z \cdot z}\right)\right) - \mathsf{fma}\left(36.52704169880642, \frac{y}{z}, 15.234687407 \cdot \left(t \cdot \frac{y}{{z}^{3}}\right)\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022081 
(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))))