```python
from sympy import *
import math
init_printing()
```


```python
x=IndexedBase('x')
y=IndexedBase('y')
p=IndexedBase('p')
q=IndexedBase('q')
alpha,omega,lam=symbols('α,ω,λ')
pr,pz,r,z=symbols('p_r,p_z,r,z')
a,b,c=symbols('a,b,c')
```


```python
H=pr*pr/4+omega*omega/(4*r*r)+(alpha+2)*pz*pz/(4*alpha)-1/(2*alpha*r)-2/sqrt(r*r+z*z);H
```


```python
H.subs(r,a*q[1]+b).subs(pr,p[1]/a).subs(z,c*q[2]).subs(pz,p[2]/c)
```


```python
H_taylor=series(H,z).removeO();H_taylor
```


```python
series(H_taylor,r,1/b,5)
```


```python
hoge=1/sqrt(r*r+z*z)
hoge
```


```python
series(series(hoge,r).removeO(),z)
```


```python
def mtaylor(funexpr,x,mu,order=1):

    nvars = len(x)
    hlist = ['__h' + str(i+1) for i in range(nvars)]
    command=''
    command="symbols('"+'  '.join(hlist) +"')"
    hvar = eval(command)
    #mtaylor is utaylor for specificly defined function
    t = symbols('t')
    #substitution
    loc_funexpr = funexpr
    for i in range(nvars):
        locvar = x[i]
        locsubs = mu[i]+t*hvar[i]
        loc_funexpr = loc_funexpr.subs(locvar,locsubs)
    #calculate taylorseries
    g = 0
    for i in range(order+1):
        g+=loc_funexpr.diff(t,i).subs(t,0)*t**i/math.factorial(i)

    #resubstitute
    for i in range(nvars):
        g = g.subs(hlist[i],x[i]-mu[i])

    g = g.subs(t,1)    
    return g
```


```python
x1,x2,x3,x4,x5 = symbols('x1 x2 x3 x4 x5')
funexpr=1/(x1*x1+x2*x2)
x=[x1,x2,x3,x4,x5]
mu=[1,0,0,0,0]
mygee = mtaylor(funexpr,x,mu,order=4)
```


```python
mygee
```


```python
a=omega**(3/2)*alpha/(4*alpha+1)
b=omega**2*alpha/(4*alpha+1)
c=omega**1.5*alpha**0.5*(alpha+2)**0.25/(sqrt(2)*(4*alpha+1)**0.75)
```

8bbaa2f45835e692ca9fd599de69740d74957660
ipynb
Jupyter Notebook
Notes/LieTransform.ipynb
yonesuke/TIL
8b6d0a3e554020ac0812be741c1b3fbe9ffc1ef8
MIT
Notes/LieTransform.ipynb
yonesuke/TIL
8b6d0a3e554020ac0812be741c1b3fbe9ffc1ef8
MIT
Notes/LieTransform.ipynb
yonesuke/TIL
8b6d0a3e554020ac0812be741c1b3fbe9ffc1ef8
MIT
Qwen/Qwen-72B
1. YES
2. YES