Average Error: 29.6 → 0.6
Time: 15.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 := \frac{457.9610022158428}{z \cdot z}\\ t_2 := \frac{t}{z \cdot z}\\ \mathbf{if}\;z \leq -5147138818.563693:\\ \;\;\;\;\mathsf{fma}\left(y, \left(3.13060547623 + \left(t_2 + \left(t_1 + \frac{a}{{z}^{3}}\right)\right)\right) - \frac{\mathsf{fma}\left(t, 15.234687407, 5864.8025282699045\right)}{{z}^{3}}, x\right)\\ \mathbf{elif}\;z \leq 2971640955330196500:\\ \;\;\;\;\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, \sqrt[3]{{\left(\mathsf{fma}\left(z, \mathsf{fma}\left(z, z + 15.234687407, 31.4690115749\right), 11.9400905721\right)\right)}^{3}}, 0.607771387771\right)}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \left(3.13060547623 + \left(t_2 + \left(t_1 + \frac{1}{z \cdot z} \cdot \frac{a}{z}\right)\right)\right) - \mathsf{fma}\left(15.234687407, \frac{t}{{z}^{3}}, \frac{36.52704169880642}{z} + \frac{5864.8025282699045}{{z}^{3}}\right), x\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 := \frac{457.9610022158428}{z \cdot z}\\
t_2 := \frac{t}{z \cdot z}\\
\mathbf{if}\;z \leq -5147138818.563693:\\
\;\;\;\;\mathsf{fma}\left(y, \left(3.13060547623 + \left(t_2 + \left(t_1 + \frac{a}{{z}^{3}}\right)\right)\right) - \frac{\mathsf{fma}\left(t, 15.234687407, 5864.8025282699045\right)}{{z}^{3}}, x\right)\\

\mathbf{elif}\;z \leq 2971640955330196500:\\
\;\;\;\;\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, \sqrt[3]{{\left(\mathsf{fma}\left(z, \mathsf{fma}\left(z, z + 15.234687407, 31.4690115749\right), 11.9400905721\right)\right)}^{3}}, 0.607771387771\right)}, x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \left(3.13060547623 + \left(t_2 + \left(t_1 + \frac{1}{z \cdot z} \cdot \frac{a}{z}\right)\right)\right) - \mathsf{fma}\left(15.234687407, \frac{t}{{z}^{3}}, \frac{36.52704169880642}{z} + \frac{5864.8025282699045}{{z}^{3}}\right), x\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 (/ 457.9610022158428 (* z z))) (t_2 (/ t (* z z))))
   (if (<= z -5147138818.563693)
     (fma
      y
      (-
       (+ 3.13060547623 (+ t_2 (+ t_1 (/ a (pow z 3.0)))))
       (/ (fma t 15.234687407 5864.8025282699045) (pow z 3.0)))
      x)
     (if (<= z 2971640955330196500.0)
       (fma
        y
        (/
         (fma z (fma z (fma z (fma z 3.13060547623 11.1667541262) t) a) b)
         (fma
          z
          (cbrt
           (pow
            (fma z (fma z (+ z 15.234687407) 31.4690115749) 11.9400905721)
            3.0))
          0.607771387771))
        x)
       (fma
        y
        (-
         (+ 3.13060547623 (+ t_2 (+ t_1 (* (/ 1.0 (* z z)) (/ a z)))))
         (fma
          15.234687407
          (/ t (pow z 3.0))
          (+ (/ 36.52704169880642 z) (/ 5864.8025282699045 (pow z 3.0)))))
        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 t_1 = 457.9610022158428 / (z * z);
	double t_2 = t / (z * z);
	double tmp;
	if (z <= -5147138818.563693) {
		tmp = fma(y, ((3.13060547623 + (t_2 + (t_1 + (a / pow(z, 3.0))))) - (fma(t, 15.234687407, 5864.8025282699045) / pow(z, 3.0))), x);
	} else if (z <= 2971640955330196500.0) {
		tmp = fma(y, (fma(z, fma(z, fma(z, fma(z, 3.13060547623, 11.1667541262), t), a), b) / fma(z, cbrt(pow(fma(z, fma(z, (z + 15.234687407), 31.4690115749), 11.9400905721), 3.0)), 0.607771387771)), x);
	} else {
		tmp = fma(y, ((3.13060547623 + (t_2 + (t_1 + ((1.0 / (z * z)) * (a / z))))) - fma(15.234687407, (t / pow(z, 3.0)), ((36.52704169880642 / z) + (5864.8025282699045 / pow(z, 3.0))))), 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.6
Target1.1
Herbie0.6
\[\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 z < -5147138818.56369305

    1. Initial program 56.3

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

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

      \[\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) \]
    4. Simplified1.0

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\left(3.13060547623 + \left(\frac{t}{z \cdot z} + \left(\frac{457.9610022158428}{z \cdot z} + \frac{a}{{z}^{3}}\right)\right)\right) - \mathsf{fma}\left(15.234687407, \frac{t}{{z}^{3}}, \frac{36.52704169880642}{z} + \frac{5864.8025282699045}{{z}^{3}}\right)}, x\right) \]
    5. Taylor expanded in z around 0 1.2

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

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

    if -5147138818.56369305 < z < 2971640955330196500

    1. Initial program 0.4

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

      \[\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-cbrt-cube_binary640.3

      \[\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)}{\mathsf{fma}\left(z, \color{blue}{\sqrt[3]{\left(\mathsf{fma}\left(z, \mathsf{fma}\left(z, z + 15.234687407, 31.4690115749\right), 11.9400905721\right) \cdot \mathsf{fma}\left(z, \mathsf{fma}\left(z, z + 15.234687407, 31.4690115749\right), 11.9400905721\right)\right) \cdot \mathsf{fma}\left(z, \mathsf{fma}\left(z, z + 15.234687407, 31.4690115749\right), 11.9400905721\right)}}, 0.607771387771\right)}, x\right) \]
    4. Simplified0.3

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

    if 2971640955330196500 < z

    1. Initial program 57.6

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

      \[\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) \]
    4. Simplified0.6

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\left(3.13060547623 + \left(\frac{t}{z \cdot z} + \left(\frac{457.9610022158428}{z \cdot z} + \frac{a}{{z}^{3}}\right)\right)\right) - \mathsf{fma}\left(15.234687407, \frac{t}{{z}^{3}}, \frac{36.52704169880642}{z} + \frac{5864.8025282699045}{{z}^{3}}\right)}, x\right) \]
    5. Applied add-cube-cbrt_binary640.7

      \[\leadsto \mathsf{fma}\left(y, \left(3.13060547623 + \left(\frac{t}{z \cdot z} + \left(\frac{457.9610022158428}{z \cdot z} + \frac{a}{{\color{blue}{\left(\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}\right)}}^{3}}\right)\right)\right) - \mathsf{fma}\left(15.234687407, \frac{t}{{z}^{3}}, \frac{36.52704169880642}{z} + \frac{5864.8025282699045}{{z}^{3}}\right), x\right) \]
    6. Applied unpow-prod-down_binary640.7

      \[\leadsto \mathsf{fma}\left(y, \left(3.13060547623 + \left(\frac{t}{z \cdot z} + \left(\frac{457.9610022158428}{z \cdot z} + \frac{a}{\color{blue}{{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right)}^{3} \cdot {\left(\sqrt[3]{z}\right)}^{3}}}\right)\right)\right) - \mathsf{fma}\left(15.234687407, \frac{t}{{z}^{3}}, \frac{36.52704169880642}{z} + \frac{5864.8025282699045}{{z}^{3}}\right), x\right) \]
    7. Applied *-un-lft-identity_binary640.7

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5147138818.563693:\\ \;\;\;\;\mathsf{fma}\left(y, \left(3.13060547623 + \left(\frac{t}{z \cdot z} + \left(\frac{457.9610022158428}{z \cdot z} + \frac{a}{{z}^{3}}\right)\right)\right) - \frac{\mathsf{fma}\left(t, 15.234687407, 5864.8025282699045\right)}{{z}^{3}}, x\right)\\ \mathbf{elif}\;z \leq 2971640955330196500:\\ \;\;\;\;\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, \sqrt[3]{{\left(\mathsf{fma}\left(z, \mathsf{fma}\left(z, z + 15.234687407, 31.4690115749\right), 11.9400905721\right)\right)}^{3}}, 0.607771387771\right)}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \left(3.13060547623 + \left(\frac{t}{z \cdot z} + \left(\frac{457.9610022158428}{z \cdot z} + \frac{1}{z \cdot z} \cdot \frac{a}{z}\right)\right)\right) - \mathsf{fma}\left(15.234687407, \frac{t}{{z}^{3}}, \frac{36.52704169880642}{z} + \frac{5864.8025282699045}{{z}^{3}}\right), x\right)\\ \end{array} \]

Reproduce

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