I'm doing calculations with Series where I don't know the power of the leading order term. I would like to keep a specified number of terms, but since I don't know the leading order this is proving difficult. For instance, suppose I want only 3 terms in a series of some complicated function func[x]. I can call
This may return something like
(* 1/x^3 + 1/x^2 + 1/(2 x) + 1/6 + x/24 + x^2/120 + x^3/720 + O(x^4) *)
But, since I didn't know it was going to start at x^-3, I have computed more terms than I needed. (Or worse, it might have started at x^2 and I would not have computed enough terms.)
So, the question is, can I write a function that will expand an expression and only keep N terms (without over-expanding and truncating, which is computationally wasteful)? It seems like this should be a simple task, but I'm finding it remarkably difficult. Any ideas?