+
+static ex lgamma_series(const ex & x, const relational & rel, int order)
+{
+ // method:
+ // Taylor series where there is no pole falls back to psi function
+ // evaluation.
+ // On a pole at -m we could use the recurrence relation
+ // lgamma(x) == lgamma(x+1)-log(x)
+ // from which follows
+ // series(lgamma(x),x==-m,order) ==
+ // series(lgamma(x+m+1)-log(x)...-log(x+m)),x==-m,order);
+ // This, however, seems to fail utterly because you run into branch-cut
+ // problems. Somebody ought to implement it some day using an asymptotic
+ // series for tgamma:
+ const ex x_pt = x.subs(rel);
+ if (!x_pt.info(info_flags::integer) || x_pt.info(info_flags::positive))
+ throw do_taylor(); // caught by function::series()
+ // if we got here we have to care for a simple pole of tgamma(-m):
+ throw (std::domain_error("lgamma_series: please implemnt my at the poles"));
+ return _ex0(); // not reached
+}
+