2020年2月20日木曜日

数学 - Python - 解析学 - 関数列と関数級数 - 整級数 - 逆数(負の累乗)、基本的な整級数展開、二項定理、変形

1. $\begin{array}{l}\frac{1}{{\left(1-x\right)}^{\alpha }}\\ ={\left(1-x\right)}^{-\alpha }\\ =\sum _{n=0}^{\infty }\left(\begin{array}{c}-\alpha \\ n\end{array}\right){\left(-x\right)}^{n}\\ =\sum _{n=0}^{\infty }\left(\begin{array}{c}-\alpha \\ n\end{array}\right){\left(-1\right)}^{n}{x}^{n}\\ =\sum _{n=0}^{\infty }\frac{\left(-\alpha \right)\left(-\alpha -1\right)·\dots ·\left(-\alpha -n+1\right)}{n!}{\left(-1\right)}^{n}{x}^{n}\\ =\sum _{n=0}^{\infty }\frac{\alpha \left(\alpha +1\right)·\dots ·\left(\alpha +n-1\right)}{n!}{x}^{n}\\ =\sum _{n=0}^{\infty }\frac{\left(\alpha +n-1\right)\left(\alpha +n-2\right)·\dots ·\alpha }{n!}{x}^{n}\\ =\sum _{n=0}^{\infty }\frac{\left(\alpha +n-1\right)\left(\left(\alpha +n-1\right)-1\right)·\dots ·\left(\left(\alpha +n-1\right)-n+1\right)}{n!}{x}^{n}\\ =\sum _{n=0}^{\infty }\left(\begin{array}{c}\alpha +n-1\\ n\end{array}\right){x}^{n}\end{array}$

コード

#!/usr/bin/env python3
from sympy import symbols, sqrt, plot, summation, factorial, pprint

print('6.')

def comb(a, n):
num = 1
for n0 in range(n):
num *= (a - n0)
return num / factorial(n)

x = symbols('x')
alpha = 2
f = 1 / (1 - x) ** alpha

p = plot(f,
*[sum([comb(alpha + n - 1, n) * x ** n for n in range(m)])
for m in range(1, 10)],
(x, -1.5, 1.5),
ylim=(-10, 10),
legend=False,
show=False)

colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

for o, color in zip(p, colors):
o.line_color = color
for o in zip(p, colors):
pprint(o)

p.show()
p.save('sample6.png')


% ./sample6.py
6.
(cartesian line: (1 - x)**(-2) for x over (-1.5, 1.5), red)
(cartesian line: 1 for x over (-1.5, 1.5), green)
(cartesian line: 2*x + 1 for x over (-1.5, 1.5), blue)
(cartesian line: 3*x**2 + 2*x + 1 for x over (-1.5, 1.5), brown)
(cartesian line: 4*x**3 + 3*x**2 + 2*x + 1 for x over (-1.5, 1.5), orange)
(cartesian line: 5*x**4 + 4*x**3 + 3*x**2 + 2*x + 1 for x over (-1.5, 1.5), purp
le)
(cartesian line: 6*x**5 + 5*x**4 + 4*x**3 + 3*x**2 + 2*x + 1 for x over (-1.5, 1
.5), pink)
(cartesian line: 7*x**6 + 6*x**5 + 5*x**4 + 4*x**3 + 3*x**2 + 2*x + 1 for x over
(-1.5, 1.5), gray)
(cartesian line: 8*x**7 + 7*x**6 + 6*x**5 + 5*x**4 + 4*x**3 + 3*x**2 + 2*x + 1 f
or x over (-1.5, 1.5), skyblue)
(cartesian line: 9*x**8 + 8*x**7 + 7*x**6 + 6*x**5 + 5*x**4 + 4*x**3 + 3*x**2 +
2*x + 1 for x over (-1.5, 1.5), yellow)
%