Taylor Expansion¶
Using the same formula for real numbers, the Taylor expansion formula can be applied complex functions. A complex regular function can be expressed uniquely as following power series.
$$ \begin{align} f(z)&=\sum^\infty_{n=0} {f^{(n)}(a)\over n!}(z-a)^n\\ &=f(a)+f'(a)(z-a)+{f''(a)\over 2!}(z-a)^2+{f'''(a)\over 3!}(z-a)^3+\cdots \end{align} $$
Let us calculate the Taylor expansion of $ f(z)=e^z $ around $ z=1 $.
from sympy import symbols, series, exp, I
z = symbols("z")
series(exp(z), z, 1, 5)
Let us calculate the Taylor expansion of $ f(z)=z^2 $ around $ z=i $.
series(z**2,z,I,5)
Here is the case with $ f(z)={1\over z-2i}$ around $ z=0 $.
series(1/(z-2*I),z,0,5)
In case with non-regular function with isolated singularities, Laurent series can be used that include negative terms of the series.
$$ f(z)=\sum^\infty_{n=-\infty} {f^{(n)}(a)\over n!}(z-a)^n $$
The series()
function can be used for Laurent series. The following calculates the Laurent series of the function that includes the negative terms.
$$ f(z)={e^z\over z^2} $$
z = symbols("z")
f = exp(z) / z**2
series(f, z, 0, 5)
Let us calculate the Laurent series of the following function using series()
.
$$ f(z)={\cos(z)\over z^2} $$
from sympy import cos
f = cos(z) / z**2
series(f, z, 0, 5)
The 'series()' does not calculate the following function. First, convert $e^z$ to power series then use subs()
and replace $z$ with ${1\over z}$.
$$ f(z)=e^{1\over z} $$
f = exp(1 / z)
g = series(exp(z), z, 0, 5)
g.subs(z, 1 / z)