Fixed bug in series expansion of log.
authorJens Vollinga <vollinga@thep.physik.uni-mainz.de>
Sat, 17 Apr 2004 16:07:14 +0000 (16:07 +0000)
committerJens Vollinga <vollinga@thep.physik.uni-mainz.de>
Sat, 17 Apr 2004 16:07:14 +0000 (16:07 +0000)
ginac/inifcns_trans.cpp

index 7df32121680621edec85c584de21c5c1243e7554..872308b93f54e234a99ebf493a4416b4d6b7f1a8 100644 (file)
@@ -201,6 +201,22 @@ static ex log_series(const ex &arg,
                        // in this case n more (or less) terms are needed
                        // (sadly, to generate them, we have to start from the beginning)
                        const ex newarg = ex_to<pseries>((arg/coeff).series(rel, order+n, options)).shift_exponents(-n).convert_to_poly(true);
+                       if (n == 0 && coeff == 1) {
+                               epvector epv;
+                               ex acc = (new pseries(rel, epv))->setflag(status_flags::dynallocated);
+                               epv.reserve(2);
+                               epv.push_back(expair(-1, _ex0));
+                               epv.push_back(expair(Order(_ex1), order));
+                               ex rest = pseries(rel, epv).add_series(argser);
+                               for (int i = order-1; i>0; --i) {
+                                       epvector cterm;
+                                       cterm.reserve(1);
+                                       cterm.push_back(expair(i%2 ? _ex1/i : _ex_1/i, _ex0));
+                                       acc = pseries(rel, cterm).add_series(ex_to<pseries>(acc));
+                                       acc = (ex_to<pseries>(rest)).mul_series(ex_to<pseries>(acc));
+                               }
+                               return acc;
+                       }
                        return pseries(rel, seq).add_series(ex_to<pseries>(log(newarg).series(rel, order, options)));
                } else  // it was a monomial
                        return pseries(rel, seq);