TITLE: Algorithm for Weierstrass Preparation Theorem for Formal Power Series
QUESTION [5 upvotes]: The Weierstrass preparation theorem for formal power series rings guarantees that if a given formal series $f(z) = \sum a_k  z^k \in R[[z]]$ where $R$ is a complete local ring with maximal ideal $M$ has $a_k \in M$ for $k < n$ and $a_n \in R^* = M^c$, then
$$
f = (z^n + b_{n-1}z^{n-1} + \cdots + b_0)u
$$
where $b_k \in M$ and  $u$ is a unit in $R[[z]]$.
I need an explicit algorithm for calculating this Weierstrass polynomial (or distinguished polynomial) for a given $f$.  In my case the coefficient ring is $R = \mathbb Z_3[[x]]$, formal power series over the 3-adics.  So any algorithm would have to be robust enough to handle these coefficients.
Does anyone know of such an algorithm for a math software package?

REPLY [6 votes]: Here's an algorithm that I use. Let's call $S$ the degree-$n$ shift operation, sending $\sum c_kz^k$ to $\sum c_{n+k}z^k$, in other words the quotient when you divide a power series by $z^n$. Step 0: divide $f$ by $Sf$, giving you a power series $f_1$ such that $Sf_1\equiv 1$ modulo $M$. Step $i$, for $i > 0$: repeat. At each stage, you get a power series $f_i$ for which $Sf_i\equiv 1 $ modulo $M^i$. For a quicker variant of Step $i$ (for $i > 0$), instead multiply by $2-Sf_i$. It works because you've constructed a convergent infinite product.