Python 量子運算(一一):歐拉公式
2022/12/02
-----
Fig. 11.1. Euler's formula.
-----
代碼 11.1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # Program 11.1:Euler's formula import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt def DrawSubplot(): ax = plt.subplot(111) # basic setting theta = np.linspace(0, 2*np.pi, 100) axis = np.linspace(-1, 1, 100) zero = axis * 0 radius = 0.7 x1 = radius * np.cos(theta) y1 = radius * np.sin(theta) # basic plotting ax.plot(axis, zero, 'b') # y = 0(x_axis) ax.plot(zero, axis, 'b') # x = 0(y_axis) ax.plot(x1, y1, 'k') # cicle # vector setting coordinates = [0, 0] # original point splt_radian = np.pi / 3 splt_title = r"$e^{i\pi}+1=0$" # vector plotting vector_p = splt_radian vector = [radius*np.cos(vector_p), radius*np.sin(vector_p)] # direction plt.quiver(coordinates[0], coordinates[1], vector[0], vector[1], scale=2, color='r') # red line r_line_y = np.linspace(0, radius*np.sin(splt_radian), 100) r_line_x = r_line_y * 0 + radius * np.cos(splt_radian) ax.plot(r_line_x, r_line_y, 'r') # red arc phi = np.linspace(0, splt_radian, 100) x2 = 0.2 * np.cos(phi) y2 = 0.2 * np.sin(phi) ax.plot(x2, y2, 'r') ax.text(1.1, -0.15, "Re", color='b') ax.text(0.1, 1, "Im", color='b') ax.text(0.2, 0.1, r"$\phi$") ax.text(radius+0.1, -0.15, r"$1$") ax.text(-0.1, -0.15, r"$0$") ax.text(-0.1, radius+0.1, r"$i$") ax.text(0.1, -0.15, r"$\cos\phi$") ax.text(0.4, 0.25, r"$\sin\phi$") ax.text(radius*np.cos(vector_p)+0.1, radius*np.sin(vector_p), r"$e^{i\phi}=\cos\phi+i\sin\phi$") plt.title(splt_title, fontsize=80) ax.set_axis_off() return mpl.rcParams['text.usetex'] = True mpl.rcParams['text.latex.preamble'] = r'\usepackage{{amsmath}}' mpl.rcParams['font.size'] = 40 fig = plt.figure(figsize=(16, 16)) DrawSubplot() # plt.savefig('/content/drive/My Drive/pqc/0011_001.png') plt.show() |
解說:
-----
尤拉公式 - 維基百科,自由的百科全書
https://zh.wikipedia.org/zh-tw/%E6%AC%A7%E6%8B%89%E5%85%AC%E5%BC%8F
棣美弗定理與Euler 公式 - 中央研究院
https://web.math.sinica.edu.tw/math_media/d274/27401.pdf
毛起來說無限
毛起來說三角
毛起來說e
-----
Python 量子運算(目錄)
https://mandhistory.blogspot.com/2022/01/quantum-computing.html
-----
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。