2

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)
J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
SonerAlbayrak
  • 2,088
  • 10
  • 11
  • Please do not use the [tag:bugs] tag until other users have confirmed your observations. – J. M.'s missing motivation Mar 09 '18 at 07:58
  • My apologies, thanks for pointing that out. – SonerAlbayrak Mar 09 '18 at 08:28
  • 1
    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. – Daniel Lichtblau Mar 09 '18 at 15:53
  • I actually do not have problem with Series: It indeed does not calculate what I want however it does not give me incorrect results either. SeriesData on the other hand does give me incorrect result, that is why I think it is a bug. As an example, Series[(-x (x - a))^b, {x, Infinity, 0}] does not evaluate but replacing $x$ with $x+O[1/x]^0$ gives incorrect answer, whereas it should be Mathematically equivalent. Please see Carl Woll's answer here: https://mathematica.stackexchange.com/questions/80107/series-with-a-specified-number-of-terms/153459#153459 – SonerAlbayrak Mar 09 '18 at 18:06
  • 1
    SeriesData is using upcode in the Series world. You will see the same issue with `InputForm[Series[-x^2,{x,0,2}]^a]

    Out[7]//InputForm= (-x)^(2a)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.

    – Daniel Lichtblau Mar 09 '18 at 22:32
  • Thank you very much Daniel. I may be missing something but I still think the issue is not with Series but with SeriesData. In your example you take symbolic power of output of Series which is itself SeriesData. What I was trying to say is that Series does not treat its input as algebraic (as can be seen in the example I gave in my comment above), whereas SeriesData apparently does, but I did not consider that this was a feature. I could not find in the documentation regarding the restrictions on the realm of SeriesData, do you happen to know any explanation somewhere? – SonerAlbayrak Mar 10 '18 at 02:29
  • It is sort of implied by Series ref guide page bullet item "Series can construct standard Taylor series, as well as certain expansions involving negative powers, fractional powers, and logarithms.". Yes, there are some differences in what Series does vs. operations on an explicit SeriesData object. But the limitations for what one can expect to be correctly handled are as above. I should also note that SeriesData, being an internal form of a series, is not likely to be as fully documented as the `Series function. – Daniel Lichtblau Mar 10 '18 at 16:29
  • Thank you Daniel. – SonerAlbayrak Mar 10 '18 at 20:31

1 Answers1

3
  1. I would say that it is a bug that (-x^2)^a gets changed to (-x)^(2a). The domain of variables is clearly stated as complex, where such transformations are not valid. However, this is an error not quite on the same order as thinking that Sqrt[(E-Pi)^2] is negative.
  2. It is a bug, but I would not expect features to commute, especially when dealing with relative power series.
  3. There is no reason to suspect that evaluation of SeriesData objects even looks at assumptions. For example, Assuming[a>5,Series[x,{x,0,3}]+Series[x,{x,0,5}]^a]] does not quite give what you would expect.
  4. Since the question is a bit more tricky for symbolic exponents, I would not expect anything simple to work. For example, what do you expect from x^a+x^b, or even x^a+x^a^2?
  5. If you have symbolic exponents I would suggest substituting rational values for them, collecting the leading term using reliable methods that you already mentioned, and then recovering the leading exponent from FindSequenceFunction.
ha loa
  • 81
  • 3
  • Thanks for the help. For point 2, I mean that mathematically these two operation should commute so I think there should be an explanation why they don't here unless it is a bug. For point 3, I noted these in case I am not aware of a particular refinement. For point 4 I expect to get x^a+x^b: I don't want Mathematica to drop symbolic terms relative to each other. However, it can and should drop if I have a term x^(a+1) or x^(b+1) which multiplying with (1+O[x]) does. For point 5, even though it is indeed a good check, it is not feasible (or practical) to do that in general. – SonerAlbayrak Mar 09 '18 at 08:56