[PATCH] power::series(): handle some (trivial) singularities of the exponent...
... so GiNaC can expand expressions like cos(x)^(sin(x)/x) // (x -> 0) (1 + x)^(1/x) // x -> 0 and so on. --- ginac/pseries.cpp | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/ginac/pseries.cpp b/ginac/pseries.cpp index 4a8d7d6..c290fe0 100644 --- a/ginac/pseries.cpp +++ b/ginac/pseries.cpp @@ -1116,6 +1116,29 @@ ex power::series(const relational & r, int order, unsigned options) const must_expand_basis = true; } + bool exponent_is_regular = true; + try { + exponent.subs(r, subs_options::no_pattern); + } catch (pole_error) { + exponent_is_regular = false; + } + + if (!exponent_is_regular) { + ex l = exponent*log(basis); + // this == exp(l); + ex le = l.series(r, order, options); + // Note: expanding exp(l) won't help, since that will attempt + // Taylor expansion, and fail (because exponent is "singular") + // Still l itself might be expanded in Taylor series. + // Examples: + // sin(x)/x*log(cos(x)) + // 1/x*log(1 + x) + return exp(le).series(r, order, options); + // Note: if l happens to have a Laurent expansion (with + // negative powers of (var - point)), expanding exp(le) + // will barf (which is The Right Thing). + } + // Is the expression of type something^(-int)? if (!must_expand_basis && !exponent.info(info_flags::negint) && (!is_a<add>(basis) || !is_a<numeric>(exponent))) -- 1.7.2.3
participants (1)
-
Alexei Sheplyakov