学習環境
- Surface
- Windows 10 Pro (OS)
- Nebo(Windows アプリ)
- iPad
- MyScript Nebo - MyScript(iPad アプリ(iOS))
- 参考書籍
解析入門 原書第3版 (S.ラング(著)、松坂 和夫(翻訳)、片山 孝次(翻訳)、岩波書店)の第Ⅴ部(“ε-δ”その他)、付録1(εとδ)、2(極限)の練習問題4を求めてみる。
コード
#!/usr/bin/env python3
from sympy import pprint, symbols, plot, Limit, oo, Rational
print('4.')
x, n = symbols('x, n')
f = x ** n / (1 + x ** n)
xs = [-2, -1, -Rational(1, 2), 0, Rational(1, 2), 1, 2]
for x0 in xs:
print(f'x = {x0}')
f0 = f.subs({x: x0})
for n0 in range(1, 11):
o = f0.subs({n: n0})
if o.is_real:
print(float(o))
else:
print(o)
print()
p = plot(*[f.subs({x: x0}) for x0 in xs],
(n, 2, 5),
show=False,
legend=True)
colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']
for o, color in zip(p, colors):
o.line_color = color
p.show()
p.save('sample4.png')
入出力結果(Zsh、cmd.exe(コマンドプロンプト)、Terminal、Jupyter(IPython))
% ./sample4.py
4.
x = -2
2.0
0.8
1.1428571428571428
0.9411764705882353
1.032258064516129
0.9846153846153847
1.0078740157480315
0.9961089494163424
1.0019569471624266
0.9990243902439024
x = -1
zoo
0.5
zoo
0.5
zoo
0.5
zoo
0.5
zoo
0.5
x = -1/2
-1.0
0.2
-0.14285714285714285
0.058823529411764705
-0.03225806451612903
0.015384615384615385
-0.007874015748031496
0.0038910505836575876
-0.0019569471624266144
0.000975609756097561
x = 0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
x = 1/2
0.3333333333333333
0.2
0.1111111111111111
0.058823529411764705
0.030303030303030304
0.015384615384615385
0.007751937984496124
0.0038910505836575876
0.001949317738791423
0.000975609756097561
x = 1
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
x = 2
0.6666666666666666
0.8
0.8888888888888888
0.9411764705882353
0.9696969696969697
0.9846153846153847
0.9922480620155039
0.9961089494163424
0.9980506822612085
0.9990243902439024
%
0 コメント:
コメントを投稿