Problem:
I need to find the leading order term in an expansion whose leading order behavior is a priori unknown. I can of course go with Series and try different orders, say Series[f[x],{x,x0,n}]
for different $n$, however I would like to find a more elegant way. Also each calculation takes very long (almost an hour) so this is not an efficient way (that it takes so long is because my function is convoluted and involves special functions, mostly hypergeometric functions).
There is already a very elegant answer to this question here: Series with a specified number of terms . Basically, it replaces the variable $x$ with its series data version, say $x+O[x]^2$, and then truncates the extra terms by multiplying another SeriesData object. For example,
(x^2 Sin[a x]^2 /. x -> Series[x, {x, 0, 1}]) (1 + O[x])
gives the correct leading order term $a x^4$.
My problem with this approach is that replacing $x$ with its SeriesData version gives incorrect results for symbolic powers. For example, let us consider the function $\left(-x^2\right)^a \sin (x)$. We see that
FullSimplify[((-x^2)^a Sin[x] /. x -> Series[x, {x, 0, 1}]) (1 + O[x]) /. a ->1/2, x > 0]
gives incorrect result -x^2+O[x]^3
whereas the correct result is I x^2+O[x]^3
as can be obtained via
FullSimplify[Series[(-x^2)^a Sin[x], {x, 0, 1}] /. a -> 1/2, x > 0]
This problem can be avoided, at least in this particular example, if one does not use the SeriesData replacement but only chops off higher order terms with the command:
FullSimplify[((-x^2)^a Sin[x]) (1 + O[x]) /. a -> 1/2, x > 0]
Also, the problem does not arise if the symbolic coefficient is given from the beginning since
(-x^2)^(-1/2) /. x -> Series[x, {x, 0, 1}]
yields $$ \begin{cases} \left(\frac{1}{\sqrt{-x^2}}\right)^*+O\left(x^1\right) & -\Im\left(x^2\right)<0 \\ \frac{1}{\sqrt{-x^2}}+O\left(x^1\right) & \text{True} \end{cases}$$ accounting probable complex nature of $x$ whereas the same command fails for symbolic power as
(-x^2)^a /. x -> Series[x, {x, 0, 1}]
directly yields $$(-x)^{2 a} \left(1+O\left(x^1\right)\right) $$
Questions
- Is it a bug that Mathematica evaluates $(-x^2)^a$ to $(-x)^{2a}$ when $x$ is replaced with a SeriesData form $x+O[x]^2$ ?
- If it is not a bug, then why do this feature not commute with replacing a symbolic power? (I am under the impression that $a\to 1/2$ should commute with $x\to x+O[x]^2$)
- I tried wrapping with Assuming, giving the information $x>0$ etc in \$Assumptions and using \$Pre=Refine etc but none of them helped. Does anyone have any idea that I can use to ensure that replacing $x$ with SeriesData works correctly?
- My main requirement is actually finding the leading order term. Would only multiplying with $(1+O[x])$ at the end works as well? (It works for this small example but my function is a long expression including tens of hypergeometric functions so I am uncertain how much this method would work)
- Does anyone know any alternative way for finding leading order term in a series expansion with symbolic exponents?
- I am using version 11.2 Is the situation same in other versions? (I plan to upgrade once 11.3 is released this month)
Series
does not do well with symbolic powers. It's not a bug per se, its a limitation since this falls outside the scope of what it will handle. $\endgroup$SeriesData
is using upcode in theSeries
world. You will see the same issue withInputForm[Series[-x^2,{x,0,2}]^a] Out[7]//InputForm= (-x)^(2*a)*SeriesData[x, 0, {1}, 0, 1, 1]
. It's basically doing what it is supposed to do, but operating outside the realm of algebraic functions. Getting it to behave inside that realm, e.g. with rational powers, has been dicey already. $\endgroup$