I am working with complicated expressions expr that contains the symbolic function f[x] which I know to have a pole at x=0. I would like to carry out Series expansions of expr and therefore f[x] near x=0 in Mathematica. The default behavior of Series is to yield a SeriesData that starts at zero powers of x:

Series[f[x],{x,0,1}] // FullForm

(* SeriesData[x, 0, List[f[0], Derivative[1][f][0]], 0, 2, 1] *)

enter image description here

This output is correct as long as f[x] is regular at x=0. But the f[x] I'm using has a pole at x=0. How do I tell Series to start the expansion of f[x] at order x^-1?

I basically need the behavior:

Series[f[x],{x,0,1}] // FullForm

(* SeriesData[x, 0, List[fRef[0], Derivative[1][fReg][0]], Derivative[2][fReg][0]], -1, 2, 1] *)

enter image description here

  1. I especially need to avoid globally defining down-values of f[x] as in f[x]:=g[x]/x since I would like to keep f[x] intact throughout the rest of the evaluations in the notebook. However, if such a definition can be made to be confined within the Series function, that would be perfectly fine.

  2. I also would not like to define a whole new SeriesNew function: I'm writing a package and I prefer the user to be able to functions already familiar to him.

My attempt:

I tried to define an up-value for f[x]:

Series[f[x_], y__] ^:= Series[1/x, y] Series[fReg[x], y];
(* SeriesData[x, 0, List[f2[0], Derivative[1][f2][0]], -1, 1, 1] *)

enter image description here

Which is OK (except that the order $\mathcal{O}(x^1)$ term is hidden). But then Series reverts back to its default assumption about f[x] when I have a more complicated expresssion involving f[x]:

Series[x f[x] + Cos[x], {x, 0, 2}]

(* SeriesData[x, 0, List[1, f[0], Plus[Rational[-1, 2], Derivative[1][f][0]]], 0, 3, 1] *)

Dream: it would be perfect if I could edit the built-in Series[expr_, ...] function so that I can add at the very top, the following line:

expr /. f[x]- >1/x g[x]

and that it can see the pole at x=0, and treat the symbolic g[x] as a regular function.

enter image description here


I feel like Series is a function that is designed and intended to give the power series (not Laurent series) expansion of a function.

It does its best, so if you did something like Series[Cos[x]/x,{x,0,10}] you will get the Laurent series though. However, if you are using unspecified f[x], it will assume f[x] has a power series expansion and give it (as you have seen).

If your function f[x] is really not specified, you may still want this expansion but you want it to include the appropriate $x^{-1}$ term in the series. You can $f(x)=g(x)/x$ and just do Series[g[x]/x,{x,0,10}]. You would then need to clean up that expression to be in terms of $f$ instead of $g$, which you can do as:

DRule[n_] :=
 If[n == 0, g[0] -> Residue[f[x], x, 0],
    ReplaceAll[D[x f[x] == g[x], {x, n}], x -> 0],
    ReplaceAll[D[g[x], {x, n}], x -> 0]
    ][[1, 1]]
s[x_]=Series[g[x]/x, {x, 0, 10}]
ReplaceAll[s[x], Table[DRule[n], {n, 0, 10}]]

You probably will find an easy pattern to eliminate the need for a DRule function that is quite so complicated, i.e. $g^{(n)}(0)=nf^{(n-1)}(0)$.

I'm not sure if this is what you want because it's not clear to me what you want to do with this expression once you have it. Please add a comment if there's something more that might help.

| improve this answer | |
  • $\begingroup$ I wrote answer answer to my own question here: mathematica.stackexchange.com/questions/60891/…. It looks like it is possible to define upvalues for Series. But as I mentioned there, it doesn't work for compound expressions. Is there a workaround? $\endgroup$ – QuantumDot Oct 14 '14 at 1:43
  • 1
    $\begingroup$ Series seems to be smart enough to recognize that certain special functions have a pole. For example, Series[Gamma[x]],{x,0,1} and Series[BesselY[1,x]],{x,0,1} all give a leading 1/x. So either Series or the special function have some information that has been set... $\endgroup$ – QuantumDot Oct 14 '14 at 1:56
  • 1
    $\begingroup$ I also give an example where Series recognizes a pole. However, it will not do so with expressions containing unspecified functions like f[x] -- it will assume $f(x)$ is regular at the center of your series. You've asked for a work-around. I've provided one. If this one doesn't work for you, you'll have to explain why it doesn't work so I (or someone else) can improve it. $\endgroup$ – Kellen Myers Oct 14 '14 at 14:51

If you give UpValues for the private symbol System`Private`InternalSeries instead, you should get the behavior you want:

f /: System`Private`InternalSeries[f[x_], {y_, y0_, n_}] := System`Private`InternalSeries[
    {y, y0, n}


Series[f[x], {x, 0, 1}] //TeXForm

$\frac{g(0)}{x}+g'(0)+\frac{1}{2} x g''(0)+O\left(x^2\right)$

and something more complicated:

Series[x f[x^2] + f[Cos[x]], {x, 0, 2}] //TeXForm

$\frac{g(0)}{x}+g(1)+x g'(0)+\frac{1}{2} x^2 \left(g(1)-g'(1)\right)+O\left(x^3\right)$

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.