2019年4月9日火曜日

数学 - Python - 解析学 - 級数 - テイラーの公式 - 指数関数(平方、逆数、置換積分法、積分、近似、剰余項の評価)

1. 置換積分法。

$\begin{array}{l}t={x}^{2}\\ \frac{\mathrm{dx}}{\mathrm{dx}}=2x\\ t=0,x=0\\ t=1,x=1\\ x=\sqrt{t}\\ \underset{0}{\overset{1}{\int }}{e}^{\left(-{x}^{2}\right)}\mathrm{dx}\\ =\frac{1}{2}\underset{0}{\overset{1}{\int }}\frac{{e}^{-t}}{\sqrt{t}}\mathrm{dt}\\ {e}^{-t}=1-t+\frac{1}{2!}{t}^{2}-\frac{1}{3!}{t}^{3}+\frac{1}{4!}{t}^{4}-\frac{1}{5!}{t}^{5}+{R}_{6}\left(t\right)\\ \left|{R}_{6}\left(t\right)\right|\le {e}^{-0}·\frac{{\left|t\right|}^{6}}{6!}=\frac{{\left|t\right|}^{6}}{6!}\end{array}$

よって、

$\begin{array}{l}\frac{{e}^{\left(-t\right)}}{\sqrt{t}}=\frac{1}{\sqrt{t}}-\sqrt{t}+\frac{1}{2!}t\sqrt{t}-\frac{1}{3!}{t}^{2}\sqrt{t}+\frac{1}{4!}t\sqrt[3]{t}-\frac{1}{5!}t\sqrt[4]{t}+\frac{{R}_{6}\left(t\right)}{\sqrt{t}}\\ \left|\frac{{R}_{6}\left(t\right)}{\sqrt{t}}\right|\le \frac{t\sqrt[5]{t}}{6!}\end{array}$

ゆえに、

$\begin{array}{l}\underset{0}{\overset{1}{\int }}{e}^{\left(-{x}^{2}\right)}\mathrm{dx}\\ =\frac{1}{2}{\left[2\sqrt{t}-\frac{2}{3}t\sqrt{t}+\frac{2}{5}·\frac{1}{2!}{t}^{2}\sqrt{t}-\frac{2}{7}·\frac{1}{3!}t\sqrt[3]{t}+\frac{2}{9}·\frac{1}{4!}t\sqrt[4]{t}-\frac{2}{11}·\frac{1}{5!}t\sqrt[5]{t}\right]}_{0}^{1}\\ +\frac{1}{2}\underset{0}{\overset{1}{\int }}\frac{{R}_{6}\left(t\right)}{\sqrt{t}}\mathrm{dt}\\ \frac{1}{2}\underset{0}{\overset{1}{\int }}\left|\frac{{R}_{6}\left(t\right)}{\sqrt{t}}\right|\mathrm{dt}\\ \le \frac{1}{2}\underset{0}{\overset{1}{\int }}\frac{t\sqrt[5]{t}}{6!}\mathrm{dt}\\ =\frac{1}{13}·\frac{1}{6!}\\ \le 1{0}^{-3}\end{array}$

よって、求める積分の小数第3位までの値は、

$1-\frac{1}{3}+\frac{1}{5·2!}-\frac{1}{7·3!}+\frac{1}{9·4!}-\frac{1}{11·5!}$

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, exp, plot, factorial, Integral, Rational

print('11-(b).')

x = symbols('x')
f = exp(-x ** 2)
If = Integral(f, (x, 0, 1))
y = sum([(-1) ** k / ((2 * k + 1) * factorial(k)) for k in range(6)])

for o in [If, If.doit(), float(If.doit()), float(y)]:
pprint(o)
print()

g = sum([(-1) ** k * 1 / ((2 * k + 1) * factorial(k)) *
x ** Rational(2 * k + 1, 2)
for k in range(6)])
p = plot(f, g, y,
(x, -2, 2),
ylim=(-5, 5),
show=False, legend=False)
colors = ['red', 'green', 'blue', 'brown']

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

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


C:\Users\...>py sample11.py
11-(b).
1
⌠
⎮    2
⎮  -x
⎮ ℯ    dx
⌡
0

√π⋅erf(1)
─────────
2

0.746824132812427

0.7467291967291967

C:\Users\...>