黒木玄
2018年7月30日(月)
次のリンク先で綺麗に閲覧できる:
$ \newcommand\eps{\varepsilon} \newcommand\ds{\displaystyle} \newcommand\Z{{\mathbb Z}} \newcommand\R{{\mathbb R}} \newcommand\C{{\mathbb C}} \newcommand\QED{\text{□}} \newcommand\root{\sqrt} \newcommand\bra{\langle} \newcommand\ket{\rangle} \newcommand\d{\partial} \newcommand\sech{\operatorname{sech}} \newcommand\cosec{\operatorname{cosec}} \newcommand\sign{\operatorname{sign}} \newcommand\sinc{\operatorname{sinc}} \newcommand\real{\operatorname{Re}} \newcommand\imag{\operatorname{Im}} \newcommand\Li{\operatorname{Li}} \newcommand\np[1]{:\!#1\!:} \newcommand\PROD{\mathop{\coprod\kern-1.35em\prod}} $
using SymPy
Beta(x,y) = gamma(x)*gamma(y)/gamma(x+y)
# sympy[:init_printing](order="rev-lex")
# sympy[:init_printing](order="lex") # default
using Plots
gr()
ENV["PLOTS_TEST"] = "true";
$\tan x$ のMaclaurin展開を5次の項まで求めよう. $f(x) = \tan x$ とおくと, $f'=1+f^2$ なので $f''=2f+2f^3$,
$$ f'''=2+8f^2+6f^4, \quad f^{(4)}=16f+40f^3+24f^5, \quad f^{(5)}=16+136f^2+240f^4+120f^6 $$となりので,
$$ f(0)=f''(0)=f^{(4)}(0)=0, \quad f'(0)=1, \quad \frac{f'''(0)}{3!}=\frac{2}{3!}=\frac{1}{3}, \quad \frac{f^{(5)}(0)}{5!}=\frac{16}{5!}=\frac{2}{15} $$ゆえに,
$$ \tan x = x + \frac{x^3}{3} + \frac{2x^5}{15} + O(x^6). $$x = symbols("x")
f(x) = tan(x)
sympy[:init_printing](order="rev-lex")
diff(f(x), x) |> display
diff(f(x), x, 2) |> expand |> display
diff(f(x), x, 3) |> expand |> display
diff(f(x), x, 4) |> expand |> display
diff(f(x), x, 5) |> expand |> display
sympy[:init_printing](order="lex") # default
# [1] (1)
x = symbols("x")
series(tan(x), x, n=10)
$x=0.5$ のとき,
$$ x = 0.5, \quad x + \frac{x^3}{3} = 0.541666\cdots, \quad x + \frac{x^3}{3} + \frac{x^5}{5} = 0.548333\cdots $$これより, $\tan 0.5 = 0.54\cdots$ であることがわかる.
# [1] (2)
@show x = 0.5
@show tan(x)
@show x
@show x+x^3/3
@show x+x^3/3+2x^5/15
@show x+x^3/3+2x^5/15+17*x^7/315;
x = 0.5 = 0.5 tan(x) = 0.5463024898437905 x = 0.5 x + x ^ 3 / 3 = 0.5416666666666666 x + x ^ 3 / 3 + (2 * x ^ 5) / 15 = 0.5458333333333333 x + x ^ 3 / 3 + (2 * x ^ 5) / 15 + (17 * x ^ 7) / 315 = 0.5462549603174602
$|x|<1$ のとき,
$$ \log\frac{1+x}{1-x} = \log(1+x)-\log(1-x) = 2\sum_{k=0}^\infty\frac{x^{2k+1}}{2k+1} = 2x+\frac{2x^3}{3}+\frac{2x^5}{5}+\cdots. $$$x=1/3$ のとき, $\ds\frac{1+x}{1-x}=2$ であり,
$$ 2x + \frac{2x^3}{3} = 0.691\cdots, \quad \frac{2x^5}{5} = \frac{2}{5\times 243} < \frac{2}{1000} = 0.002\cdots. $$これより $\log 2 = 0.69\cdots$ であることがわかる.
解説: $\log 2 \approx 0.7$ は「70%ルール」として役にたっている. 年利 $r\%$ の金利の複利計算で約何年後に2倍になるかは $70/r$ でわかる. なぜならば, $\approx(1+r/100)^x = 2$ の解は $e^{rx/100}=2$ の解で近似され, その解 $\ds x=\frac{100\log 2}{r}$ は $100\log 2\approx 70$ より $70/r$ で近似される. $\QED$
# [2]
x = Sym(:x)
series(log(1+x)-log(1-x), x, n=10)
x = 1/3
@show (1+x)/(1-x)
@show log(2)
@show 2x
@show 2x + 2*x^3/3
@show 2x + 2*x^3/3 + 2*x^5/5
@show 2x + 2*x^3/3 + 2*x^5/5 + 2*x^7/7;
(1 + x) / (1 - x) = 1.9999999999999998 log(2) = 0.6931471805599453 2x = 0.6666666666666666 2x + (2 * x ^ 3) / 3 = 0.691358024691358 2x + (2 * x ^ 3) / 3 + (2 * x ^ 5) / 5 = 0.6930041152263374 2x + (2 * x ^ 3) / 3 + (2 * x ^ 5) / 5 + (2 * x ^ 7) / 7 = 0.6931347573322881
$\ds \int_{-\infty}^\infty e^{-x^2/2}\cos(px)\,dx = \sqrt{2\pi}\;e^{-p^2/2}$
$$ \begin{aligned} & \int_{-\infty}^\infty e^{-ax^2}x^{2k}\,dx = \left(-\frac{\d}{\d a}\right)^k\int_{-\infty}^\infty e^{-ax^2}\,dx = \left(-\frac{\d}{\d a}\right)^k \sqrt{\pi}\;a^{-1/2}, \\ &\qquad = \sqrt{\pi}\;\frac{1}{2}\frac{3}{2}\cdots\frac{2k-1}{2}a^{-1/2-k} = \sqrt{\pi}\;\frac{(2k)!}{2^{2k}k!}a^{-1/2-k}, \\ & \int_{-\infty}^\infty e^{-x^2/2}x^{2k}\,dx = \sqrt{2\pi}\;\frac{(2k)!}{2^k k!}, \\ & \int_{-\infty}^\infty e^{-x^2/2}\cos(px)\,dx = \sum_{k=0}^\infty (-1)^k\frac{p^{2k}}{(2k)!}\int_{-\infty}^\infty e^{-x^2/2}x^{2k}\,dx \\ &\qquad = \sum_{k=0}^\infty (-1)^k\frac{p^{2k}}{(2k)!} \sqrt{2\pi}\;\frac{(2k)!}{2^k k!} = \sqrt{2\pi}\sum_{k=0}^\infty \frac{(-p^2/2)^k}{k!} = \sqrt{2\pi}\;e^{-p^2/2}. \end{aligned} $$# [3]
p = symbols("p", positive=true)
x = symbols("x", real=true)
integrate(e^(-x^2/2)*cos(p*x), (x,-oo,oo))
および
$$ B(p,q) = \frac{\Gamma(p)\Gamma(q}{\Gamma(p+q)}, \quad \Gamma(s+1)=s\Gamma(s),\quad \Gamma(1/2) = \sqrt{\pi}, \quad \Gamma(n+1) = n! $$を使う.
# [4] (1)
x = symbols("x", positive=true)
integrate(x^(Sym(5)/2)/√(1-x), (x,0,1))
Beta(Sym(7)/2,Sym(1)/2)
# [4] (2)
x = symbols("x", positive=true)
integrate(x^(Sym(5)/2)/(1+x)^5, (x,0,oo))
Beta(Sym(7)/2, Sym(3)/2)
# [4] (3)
2integrate(cos(x)^6*sin(x)^4, (x,0,PI/2))
Beta(Sym(7)/2, Sym(5)/2)
# [5] (1)
f(x) = x * log(x)
x = symbols("x", positive=true)
f1 = diff(f(x), x) |> display
f2 = diff(f(x), x, x) |> display
$\displaystyle E[g(x)] = \sum_{i=1}^n p_i g(q_i/p_i)$ は期待値汎函数なので, Jensenの不等式より, 下に凸な函数 $g(x)$ に対して $E[g(x)]\leqq g(E[x])$ なので, それを $f(x)$ に適用すると,
$$ \begin{aligned} \sum_{i=1}^n q_i\log\frac{q_i}{p_i} = \sum_{i=1}^n p_i\frac{q_i}{p_i}\log\frac{q_i}{p_i} = E[f(x)] \geqq f(E[x]) = f\left(\sum_{i=1}^n p_i\frac{q_i}{p_i}\right) = f(1) = 0. \end{aligned} $$解説: この結果はGibbsの(情報)不等式と呼ばれている. $\QED$
$\ds f_n(y) =e^{-\sqrt{n}\;y}\left(1+\frac{y}{\sqrt{n}}\right)^n$ とおくと, $|y/\sqrt{n}|<1$ のとき,
$$ \begin{aligned} \log f_n(y) &= -\sqrt{n}\;y + n\log\left(1+\frac{y}{\sqrt{n}}\right) = -\sqrt{n};y + n\left(\frac{y}{\sqrt{n}} - \frac{y^2}{2n} + \frac{y^3}{3n\sqrt{n}} - \frac{y^4}{4n^2} + \cdots\right) \\ &= - \frac{y^2}{2} + \frac{y^3}{3\sqrt{n}} - \frac{y^4}{4n} +\cdots \to -\frac{y^2}{2} \qquad(n\to\infty). \end{aligned} $$ゆえに $n\to\infty$ のとき, $f_n(y)\to e^{-y^2/2}$.
# [6] (1)
y = symbols("y", positive=true)
n = symbols("n", positive=true)
limit(e^(-√n*y)*(1+y/√n)^n, n=>oo)
y = symbols("y", real=true)
n = symbols("n", positive=true)
series(log(e^(-√n*y)*(1+y/√n)^n), y) |> display
limit(series(log(e^(-√n*y)*(1+y/√n)^n), y), n=>oo)
$x = n + \sqrt{n}\;y = n(1+y/\sqrt{n})$ とおくと, $n\to\infty$ のとき,
$$ \begin{aligned} \frac{1}{n^n e^{-n}\sqrt{n}}\int_0^\infty e^{-x}x^n\,dx &= \frac{1}{n^n e^{-n}\sqrt{n}}\int_{-\sqrt{n}}^\infty e^{-n-\sqrt{n}\;y}n^n\left(1+\frac{y}{\sqrt{n}}\right)^n\sqrt{n}\,dy \\ &= \int_{-\sqrt{n}}^\infty e^{-\sqrt{n}\;y}\left(1+\frac{y}{\sqrt{n}}\right)^n\,dy \to\int_{-\infty}^\infty e^{-y^2/2}\,dy = \sqrt{2\pi}. \end{aligned} $$# [7] (1)
n = symbols("n", positive=true)
limit(n^(1/n), n=>oo)
Stirlingの公式と(1)より, $n\to\infty$ のとき
$$ \begin{aligned} & \binom{n(a+b)}{na} = \frac {(n(a+b))^{n(a+b)}e^{-n(a+b)}\sqrt{2\pi n(a+b)}} {(na)^{na}(nb)^{nb}e^{-na-nb}\sqrt{2\pi na\;2\pi nb}} = \left( \frac {(a+b)^{a+b}} {a^a b^b} \right)^n \sqrt{\frac{a+b}{2\pi nab}} \end{aligned} $$なので,
$$ \lim_{n\to\infty}\binom{n(a+b)}{na}^{1/n} = \frac{(a+b)^{a+b}}{a^a b^b}. $$解説: この結果の対数はエントロピーの話と関係がある. $\QED$
# [7] (2)
n, a, b = symbols("n a b", positive=true)
simplify(limit((gamma(n*(a+b)+1)/(gamma(n*a+1)*gamma(n*b+1)))^(1/n), n=>oo))
二項展開によって, $0<x<1$ のとき,
$$ \begin{aligned} & (-1)^n\binom{-1/2}{n} = \frac{(1/2)(3/2)\cdots((2n+1)/2)}{n!} = \frac{1\cdot3\cdots(2n-1)}{2^n n!} = \frac{(2n)!}{2^{2n} (n!)^2} = \binom{2n}{n}2^{-2n}, \\ & (1-x)^{-1/2} = \sum_{n=0}^\infty \binom{-1/2}{n}(-x)^n = \sum_{n=0}^\infty \binom{2n}{n}2^{-2n}x^n \end{aligned} $$なので, $\Gamma(1/2)=\sqrt{\pi}$, $\Gamma(1)=1$ を使うと,
$$ \begin{aligned} \pi &= \frac{\Gamma(1/2)\Gamma(1/2)}{\Gamma(1)} = B(1/2,1/2) = \int_0^1 x^{-1/2}(1-x)^{-1/2}\,dx \\ &= \sum_{n=0}^\infty \binom{2n}{n}2^{-2n}\int_0^1 x^{n-1/2}\,dx = \sum_{n=0}^\infty \binom{2n}{n}\frac{2^{-2n}}{n+1/2}. \end{aligned} $$# [8]
n = symbols("n", integer=true)
doit(Sum(binomial(2n,n)*2^(-2n)/(n+Sym(1)/2), (n,0,oo)))
Beta(Sym(1)/2, Sym(1)/2) # B(1/2,1/2)