Commit 43b3824c authored by Wenchao Zhang's avatar Wenchao Zhang ✍️
Browse files

add 共轭上三角的转化

parent 4eab1d6a
Loading
Loading
Loading
Loading
+67 −0
Original line number Diff line number Diff line
%% Cell type:code id: tags:

``` 
from sympy import *
x = symbols ('x')
f = symbols('f', cls=Function)
dsolve(f(x).diff(x)- cos(f(x)), f(x))
```

%% Output

    [Eq(f(x), pi - asin(1/tanh(C1 + x))), Eq(f(x), asin(1/tanh(C1 + x)))]

%% Cell type:code id: tags:

``` 
# 计算所有满足 M^2=I 的整系数矩阵, 无法使用这一方法计算 M^3
from sympy import *
a, b, c, d = symbols('a b c d');
M=Matrix([[a,b],[c,d]]);
K=M*M
N=Matrix([[1,0],[0,1]]);
solve(Eq(K,N),(a,b,c,d))
```

%% Output

    [(-1, 0, 0, -1),
     (-1, 0, 0, 1),
     (-1, 0, c, 1),
     (1, 0, 0, -1),
     (1, 0, 0, 1),
     (1, 0, c, -1),
     (-d, (1 - d**2)/c, c, d)]

%% Cell type:code id: tags:

``` 
# 计算所有满足 M^3=I 的整系数矩阵
from sympy import *
a, b, c, d = symbols('a b c d');
M=Matrix([[a,b],[c,d]]);
K=M**3
N=Matrix([[1,0],[0,1]]);
solve(Eq(K,N),(a,b,c,d))
```

%% Cell type:code id: tags:

``` 
# 计算共轭上三角,对应线性函数变化
from sympy import *
a, b, c, d = symbols('a b c d');
M = Matrix([[a,b],[(1-a**2)/b,-a]])
S = Matrix([[-b/(1+a),1],[1,0]])
T=S.inv()
T*M*S
```

%% Output

$\displaystyle \left[\begin{matrix}- a - \frac{1 - a^{2}}{a + 1} & \frac{1 - a^{2}}{b}\\- \frac{a b}{a + 1} + b - \frac{b \left(a + \frac{1 - a^{2}}{a + 1}\right)}{a + 1} & a + \frac{1 - a^{2}}{a + 1}\end{matrix}\right]$
    Matrix([
    [                              -a - (1 - a**2)/(a + 1),           (1 - a**2)/b],
    [-a*b/(a + 1) + b - b*(a + (1 - a**2)/(a + 1))/(a + 1), a + (1 - a**2)/(a + 1)]])

%% Cell type:code id: tags:

``` 
# 共轭上三角实例
from sympy import *
M=Matrix([[3,-2],[4,-3]])
N=Matrix([[1,1],[1,0]])
K=N.inv()
K*M*N
```

%% Output

$\displaystyle \left[\begin{matrix}1 & 4\\0 & -1\end{matrix}\right]$
    Matrix([
    [1,  4],
    [0, -1]])

%% Cell type:code id: tags:

``` 
# 验证 m=-1/(1+x) 虽然满足 m^3=1 但对应矩阵表示不满足.
from sympy import *
M = Matrix([[0,1],[(-1),1]])
M**3
```

%% Output

$\displaystyle \left[\begin{matrix}-1 & 0\\0 & -1\end{matrix}\right]$
    Matrix([
    [-1,  0],
    [ 0, -1]])

%% Cell type:code id: tags:

``` 
```