Processing math: 100%

Pythonで複素関数を描画する

python

Pythonで複素関数を描画する。例では

\begin{align} f(z)=\frac{1}{z} \end{align}

を可視化している。z=0に特異点があることが確認できる。

実行結果

ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import numpy as np
import matplotlib.pyplot as plt
 
 
X0, X1, dx = -0.01, 0.01, 0.001
Y0, Y1, dy = -0.01, 0.01, 0.001
 
x = np.arange(X0, X1, dx)
y = np.arange(Y1, Y0, -dy)
 
x, y = np.meshgrid(x, y)
 
z = x + y * 1j
f = 1/z
 
norm_f = np.sqrt(f.real ** 2 + f.imag ** 2)
 
plt.subplot(131)
plt.imshow(f.real)
plt.subplot(132)
plt.imshow(f.imag)
plt.subplot(133)
plt.imshow(norm_f)
plt.show()

コメント

タイトルとURLをコピーしました