## 2019年12月9日月曜日

### 数学 - Python - 解析学 - “ε-δ”その他 - 帰納法 - 奇数、平方の級数

1. $\begin{array}{l}\sum _{k=1}^{n}{\left(2k-1\right)}^{2}\\ =\sum _{k=1}^{n-1}\left(2k-1\right)+{\left(2n-1\right)}^{2}\\ =\frac{1}{3}\left(4{\left(n-1\right)}^{3}-\left(n-1\right)\right)+{\left(2n-1\right)}^{2}\\ =\frac{1}{3}\left(n-1\right)\left(4{\left(n-1\right)}^{2}-1\right)+{\left(2n-1\right)}^{2}\\ =\frac{1}{3}\left(n-1\right)\left(4{n}^{2}-8n+3\right)+4{n}^{2}-4n+1\\ =\frac{1}{3}\left(4{n}^{3}-12{n}^{2}+11n-3+12{n}^{2}-12n+3\right)\\ =\frac{1}{3}\left(4{n}^{3}-n\right)\end{array}$

よって、帰納法により、すべての正の整数 n に対して成り立つ。

（証明終）

コード

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

print('3.')

n, k = symbols('n, k', integer=True, positive=True)
square = summation((2 * k - 1) ** 2, (k, 1, n))

class MyTestCase(TestCase):
def test(self):
self.assertEqual(square, ((4 * n ** 3 - n) / 3).expand())

p = plot(square,
(n, 1, 11),
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('sample3.png')

if __name__ == '__main__':
main()


% ./sample3.py -v
3.
test (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.001s

OK
%