Read Euler's formula in Python

Introduction

It's late, but this article is the 12th day of Mathematics Advent Calendar 2016.

What is Euler's formula?

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

Source: [Euler's formula-Wikipedia](https://ja.wikipedia.org/wiki/%E3%82%AA%E3%82%A4%E3%83%A9%E3%83%BC%E3%81 % AE% E5% 85% AC% E5% BC% 8F)

Where e is an exponential function, i is an imaginary unit, and cos and sin are cosine and sine functions, respectively. It is an equation that holds for any complex number θ, but it is especially important and often used when θ is a real number. When θ is a real number, θ corresponds to the argument on the complex plane formed by the complex number eiθ (the unit of the angle θ is radians).

I will omit the official proof of Euler, but I think this article is easy to understand. What is Euler's formula? Introducing the flow of how to find Euler's equation

Comparison on the complex plane

Here, Python is used to draw both sides on the complex plane and compare whether they have the same unit circle.

Regarding the depiction on the complex plane, plotting.py introduced in Matrix Programmer /plotting.py) was used.

By the way, the imaginary number i is expressed as j in Python.

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

Now let's drop both sides of Euler's formula into the complex plane.

>>> 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)

When I tried plotting, both the left side and the right side became the following unit circles, and I found that they were equal!

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

in conclusion

This story is covered in Chapter 1 of Matrix Programmer. PDF version: http://codingthematrix.com/slides/The_Field.pdf

This book is physically and contently heavy w The PDF version is also available on the Official Site, so if you are interested, why not take a look.

Recommended Posts

Read Euler's formula in Python
Read DXF in python
Read Namespace-specified XML in Python
Read Outlook emails in Python
Read Fortran output in python
Read Protocol Buffers data in Python3
Read PNG chunks in Python (class)
Read files in parallel with Python
Create and read messagepacks in Python
Quadtree in Python --2
Python in optimization
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
Meta-analysis in Python
Unittest in python
Epoch in Python
Discord in Python
Sudoku in Python
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
Programming in python
Read the file line by line in Python
Read the file line by line in Python
Plink in Python
Constant in python
Read and write JSON files in Python
Lifegame in Python.
FizzBuzz in Python
Sqlite in python
StepAIC in Python
N-gram in python
LINE-Bot [0] in Python
Csv in python
Disassemble in Python
Reflection in Python
Constant in python
nCr in Python.
format in python
Scons in Python3
Puyo Puyo in python
python in virtualenv
PPAP in Python
Quad-tree in Python
Reflection in Python
Chemistry in Python
[Python] Read the specified line in the file
Hashable in python
DirectLiNGAM in Python
Read text in images with python OCR
LiNGAM in Python
Flatten in python
[python] Read data
flatten in python
Read a file containing garbled lines in Python
Read table data in PDF file with Python
Sorted list in Python