学習環境
- Surface
- Windows 10 Pro (OS)
- Nebo(Windows アプリ)
- iPad
- MyScript Nebo - MyScript(iPad アプリ(iOS))
- 参考書籍
解析入門(上) (松坂和夫 数学入門シリーズ 4) (松坂 和夫(著)、岩波書店)の第8章(積分の計算)、8.2(定積分の計算)、問題7の解答を求めてみる。
よって、
よって、
コード
#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import pprint, symbols, Integral, log, exp, oo, Rational, plot
print('7.')
x = symbols('x', real=True)
n = symbols('n', integer=True, nonnegative=True)
f = x ** (2 * n + 1) * exp(-x ** 2)
a = 2
g1 = x ** -Rational(1, 2) * log(x) ** n
g2 = x ** 2 * log(x) ** n
xs = [(0, oo), (0, 1), (0, 1)]
for i, (h, (x1, x2)) in enumerate(zip([f, g1, g2], xs), 1):
print(f'({i})')
I = Integral(h, (x, x1, x2))
for o in [I, I.doit()]:
pprint(o.simplify())
print()
p = plot(*[h.subs({n: n0})
for h in [f, g1, g2]
for n0 in range(3)],
(x, -5, 5),
ylim=(-5, 5),
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('sample7.png')
入出力結果(Zsh、PowerShell、Terminal、Jupyter(IPython))
% ./sample7.py
7.
(1)
∞
⌠
⎮ 2
⎮ 2⋅n + 1 -x
⎮ x ⋅ℯ dx
⌡
0
n!
──
2
(2)
1
⌠
⎮ n
⎮ log (x)
⎮ ─────── dx
⎮ √x
⌡
0
1
⌠
⎮ n
⎮ log (x)
⎮ ─────── dx
⎮ √x
⌡
0
(3)
1
⌠
⎮ 2 n
⎮ x ⋅log (x) dx
⌡
0
1
⌠
⎮ 2 n
⎮ x ⋅log (x) dx
⌡
0
(cartesian line: x*exp(-x**2) for x over (-5.0, 5.0), red)
(cartesian line: x**3*exp(-x**2) for x over (-5.0, 5.0), green)
(cartesian line: x**5*exp(-x**2) for x over (-5.0, 5.0), blue)
(cartesian line: 1/sqrt(x) for x over (-5.0, 5.0), brown)
(cartesian line: log(x)/sqrt(x) for x over (-5.0, 5.0), orange)
(cartesian line: log(x)**2/sqrt(x) for x over (-5.0, 5.0), purple)
(cartesian line: x**2 for x over (-5.0, 5.0), pink)
(cartesian line: x**2*log(x) for x over (-5.0, 5.0), gray)
(cartesian line: x**2*log(x)**2 for x over (-5.0, 5.0), skyblue)
%
0 コメント:
コメントを投稿