2019年11月27日水曜日

数学 - Python - 解析学 - “ε-δ”その他 - εとδ - 極限 - 関数、場合分け

1. $x=0$

の場合、

$\underset{n\to \infty }{\mathrm{lim}}\frac{{x}^{n}}{1+{x}^{n}}=0$
$0<\left|x\right|<1$

の場合、

$\underset{n\to \infty }{\mathrm{lim}}\frac{{x}^{n}}{1+{x}^{n}}=0$

また、

$x=1$

の場合、

$\underset{x\to \infty }{\mathrm{lim}}\frac{{x}^{n}}{1+{x}^{n}}=\frac{1}{2}$

また、

$\left|x\right|>1$

の場合、

$\begin{array}{l}\underset{n\to \infty }{\mathrm{lim}}\frac{{x}^{n}}{1+{x}^{n}}\\ =\underset{n\to \infty }{\mathrm{lim}}\frac{1}{\frac{1}{{x}^{n}}+1}\\ =1\end{array}$

コード

#!/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')


% ./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

%