Change Valuation to do Series Reversion
I've run into the problem of doing series reversion with symbolic power series a few times now, and while in the past I was able to hack together a solution (by using some inelegant combination of f.taylor()
, f.series()
, s.truncate()
, s.power_series(QQbar)
, etc.), today I wasn't able to figure out how to get what I want done.
Concretely, let's say you want to compute a power series for those $x$ such that $x \sin(x) + \cos(x) = 0$ (as indeed I do). This can only happen when $\sin(x) \approx 0$, so we want to look near $n \pi$.
Here we can cheat a little bit and use the fact that $\sin$ and $\cos$ are periodic to get a good series expansion for this. If we write $q = n \pi$, we get
q = var('q')
eps = var('eps')
s = (q + eps) * sin(eps).series(eps) + cos(eps).series(eps)
s = s.series(eps) # expand and collect terms
# symbolic power series don't have a .reverse() method
# so let's just work over a field that has a variable called q
R.<q> = PolynomialRing(QQbar)
F = FractionField(R)
S = PowerSeriesRing(F,eps)
s = S(s)
Now we have
$$ s = 1 + q \epsilon + \frac{1}{2} \epsilon^{2} -\frac{1}{6} q \epsilon^{3} -\frac{1}{8} \epsilon^{4} + \frac{1}{120} q \epsilon^{5} + \ldots $$
Since we want to know that $x \sin(x) + \cos(x) = 0$, we should set $s = 0$ and solve for $\epsilon$ (which will depend on $n$). Then our roots will be exactly $q + \epsilon$, that is, $n \pi + \epsilon$. We can do this using lagrange inversion, where if $s^{-1}$ is the inverse of $s$ we'll have $\epsilon = s^{-1}(0)$ and our problem will be solved.
Unfortunately, there's no way (as far as I know) to do lagrange inversion on a symbolic series (and in my experience symbolic power series are probably best avoided anyways. It seems like other people share this belief too). I'm happy to do this trick of working over some other field, but I'm getting an error: s.reverse()
is telling me series must have valuation one for reversion
. I think this is happening since q.valuation()
is returning $0$ for some reason. This is strange, since F(q).valuation() = 1
, as expected, but then S(F(q)).valuation() = 0
again.
Is there a way I can force sage to see that q
is invertible?
If not, is there another (better) way to handle series reversion with variable coefficients?
Thanks in advance! ^_^
More direct way to get S