2019年12月15日日曜日

数学 - Python - 解析学 - “ε-δ”その他 - 帰納法 - 二項定理の証明

1. $\begin{array}{l}{\left(x+y\right)}^{0}=1\\ \sum _{k=0}^{0}\left(\begin{array}{c}0\\ k\end{array}\right){x}^{k}{y}^{0-k}\\ =\frac{0!}{0!\left(0-0\right)!}{x}^{0}{y}^{0}\\ =1\end{array}$

よって、

${\left(x+y\right)}^{0}=\sum _{k=0}^{0}\left(\begin{array}{c}0\\ k\end{array}\right){x}^{k}{y}^{0-k}$

また、

$\begin{array}{l}{\left(x+y\right)}^{n}\\ =\left(x+y\right){\left(x+y\right)}^{n-1}\\ =\left(x+y\right)\sum _{k=0}^{n-1}\left(\begin{array}{c}n-1\\ k\end{array}\right){x}^{k}{y}^{\left(n-1\right)-k}\\ =\sum _{k=0}^{n-1}\left(\begin{array}{c}n-1\\ k\end{array}\right){x}^{k+1}{y}^{n-k-1}+\sum _{k=0}^{n-1}\left(\begin{array}{c}n-1\\ k\end{array}\right){x}^{k}{y}^{n-k}\\ =\sum _{k=1}^{n}\left(\begin{array}{c}n-1\\ k-1\end{array}\right){x}^{k}{y}^{n-\left(k-1\right)-1}+\sum _{k=0}^{n-1}\left(\begin{array}{c}n-1\\ k\end{array}\right){x}^{k}{y}^{n-k}\\ =\sum _{k=1}^{n-1}\left(\begin{array}{c}n-1\\ k-1\end{array}\right){x}^{k}{y}^{n-k}+{x}^{n}+{y}^{n}+\sum _{k=1}^{n-1}\left(\begin{array}{c}n-1\\ k\end{array}\right){x}^{k}{y}^{n-k}\\ =\sum _{k=1}^{n-1}\left(\left(\begin{array}{c}n-1\\ k-1\end{array}\right)+\left(\begin{array}{c}n-1\\ k\end{array}\right)\right){x}^{k}{y}^{n-k}+{x}^{n}+{y}^{n}\\ =\sum _{k=1}^{n-1}\left(\begin{array}{c}n\\ k\end{array}\right){x}^{k}{y}^{n-k}+\left(\begin{array}{c}n\\ n\end{array}\right){x}^{n}{y}^{n-n}+\left(\begin{array}{c}n\\ 0\end{array}\right){x}^{0}{y}^{n-0}\\ =\sum _{k=1}^{n}\left(\begin{array}{c}n\\ k\end{array}\right){x}^{k}{y}^{n-k}\end{array}$

よって、 帰納法によりすべての自然数に対して成り立つ。

（証明終）

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import symbols, binomial, summation

print('9.')

class MyTestCase(TestCase):
def test(self):
x, y = symbols('x, y')
k = symbols('k', integer=True, nonnegative=True)
for n in range(10):
self.assertEqual(((x + y) ** n).expand(),
summation(binomial(n, k) * x ** k * y ** (n - k), (k, 0, n)))

if __name__ == '__main__':
main()


% ./sample9.py -v
9.
test (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.093s

OK
%