9
6

More than 5 years have passed since last update.

Pythonでオイラーの公式を読み解く

Last updated at Posted at 2016-12-15

はじめに

遅くなりましたがこの記事は、数学 Advent Calendar 2016 12日目の記事です。

オイラーの公式とは

e^{i\theta} =\cos\theta +i\sin\theta

出典: オイラーの公式 - Wikipedia

ここで e は指数関数、i は虚数単位、cos, sin はそれぞれ余弦関数および正弦関数である。任意の複素数 θ に対して成り立つ等式であるが、特に θ が実数である場合が重要でありよく使われる。θ が実数のとき、θ は複素数 eiθ がなす複素平面上の偏角(角度 θ の単位はラジアン)に対応する。

オイラーの公式の証明に関しては、割愛しますがこの記事などがわかりやすいかと思います。
オイラーの公式とは何か?オイラーの等式の求め方の流れを紹介します

複素平面での比較

ここではPythonを用いて両辺を複素平面上に描写して、等しい単位円になるか比較します。

複素平面への描写に関しては、行列プログラマーで紹介されているplotting.pyを利用しました。

ちなみに虚数iはPythonではjと表現します。

>>> j
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'j' is not defined
>>> 1j
1j
>>> type(1j)
<type 'complex'>

それではオイラーの公式の両辺を、複素平面に落とし込みます。

>>> from plotting import plot
>>> from math import e, pi
>>> L1 = {e**(1j*theta) for theta in range(0, 360)}
>>> plot(L1)
>>> from plotting import plot
>>> from math import sin, cos
>>> L2 = {cos(theta) + 1j * sin(theta) for theta in range(0, 360)}
>>> plot(L2)

plotしてみると左辺・右辺どちらも次のような単位円となり、等しいことが見てわかりました!

スクリーンショット 2016-12-16 4.08.58.png

おわりに

この話は行列プログラマー第1章のなかで取り上げられています。
PDF版: http://codingthematrix.com/slides/The_Field.pdf

この本は物理的にも内容的にも重いですw
公式サイトでもPDF版が公開されているので、興味ある方は一度覗いてみてはいかがでしょうか。

9
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
6