極限

極限はlimit
ooは無限大
sin pai/2 = 1

from sympy import *
x = Symbol('x')
f = limit(sin(x)/x,x,oo)
print(f)

[vagrant@localhost python]$ python app.py
Traceback (most recent call last):
File “app.py”, line 1, in
from sympy import *
ModuleNotFoundError: No module named ‘sympy’

[vagrant@localhost python]$ pip install sympy
Collecting sympy
Downloading https://files.pythonhosted.org/packages/21/21/f4105795ca7f35c541d82c5b06be684dd2f5cb4f508fb487cd7aea4de776/sympy-1.4-py2.py3-none-any.whl (5.3MB)
|████████████████████████████████| 5.3MB 2.8MB/s
Collecting mpmath>=0.19 (from sympy)
Downloading https://files.pythonhosted.org/packages/ca/63/3384ebb3b51af9610086b23ea976e6d27d6d97bf140a76a365bd77a3eb32/mpmath-1.1.0.tar.gz (512kB)
|████████████████████████████████| 522kB 1.8MB/s
Building wheels for collected packages: mpmath
Building wheel for mpmath (setup.py) … done
Created wheel for mpmath: filename=mpmath-1.1.0-cp36-none-any.whl size=532240 sha256=ee5e33a6f32c6be4e88e8e90c0a201a978adcf3203bb8254e8765258844214b5
Stored in directory: /home/vagrant/.cache/pip/wheels/63/9d/8e/37c3f6506ed3f152733a699e92d8e0c9f5e5f01dea262f80ad
Successfully built mpmath
Installing collected packages: mpmath, sympy
Successfully installed mpmath-1.1.0 sympy-1.4
[vagrant@localhost python]$ python app.py
0

ほう、0なんだ。

from sympy import *
i = Symbol('i', integer=True)
n = Symbol('n', integer=True)
p = Rational(1,2)
f = summation(p**i,(i,1,n))
l = limit(f,n,oo)
print(l)

[vagrant@localhost python]$ python app.py
1

プログラミングってより、数学がわからんどダメだなー