## 2019年4月14日日曜日

### 数学 - Python - 解析学 - 級数 - テイラーの公式 - 対数関数(近似、剰余項の評価、誤差)

1. $\begin{array}{l}\mathrm{log}1.2=\mathrm{log}\left(1+0.2\right)\\ \left|{R}_{4}\right|\le \frac{{2}^{4}}{4}·1{0}^{-4}=4·1{0}^{-4}<1{0}^{-3}\\ \mathrm{log}1.2\\ \fallingdotseq 0.2-\frac{{\left(0.2\right)}^{2}}{2}+\frac{{\left(0.2\right)}^{3}}{3}\\ \fallingdotseq 0.2-0.02+0.002\\ =0.182\end{array}$

2. $\begin{array}{l}\mathrm{log}0.9=\mathrm{log}\left(1-0.1\right)\\ {R}_{3}\le \frac{1}{3·{\left(0.9\right)}^{3}}·1{0}^{-3}<1{0}^{-3}\\ \mathrm{log}0.92\\ \fallingdotseq -0.1-\frac{{\left(-0.1\right)}^{2}}{2}\\ =-0.1-0.005\\ =-0.105\end{array}$

3. $\begin{array}{l}\mathrm{log}1.05=\mathrm{log}\left(1+0.05\right)\\ \left|{R}_{3}\right|\le \frac{5}{3}·{\left(1{0}^{-2}\right)}^{3}<1{0}^{-3}\\ \mathrm{log}1.05\\ \fallingdotseq 0.05-\frac{{\left(0.05\right)}^{2}}{2}\\ =0.05-0.00125\\ \fallingdotseq 0.048\end{array}$

4. $\begin{array}{l}\left|{R}_{3}\right|<1{0}^{-3}\\ \mathrm{log}\frac{9}{10}=\mathrm{log}0.9\fallingdotseq -0.105\end{array}$

5. $\begin{array}{l}\mathrm{log}\frac{24}{25}\\ =\mathrm{log}\left(1-\frac{1}{25}\right)\\ =\mathrm{log}\left(1-0.04\right)\\ \left|{R}_{3}\right|\\ \le \frac{{\left(0.04\right)}^{3}}{3·0.96}\\ <1{0}^{-3}\\ \mathrm{log}\frac{24}{25}\\ \fallingdotseq 0.04-\frac{{\left(-0.04\right)}^{2}}{2}\\ =-0.04-0.0008\\ \fallingdotseq -0.040\end{array}$

6. $\begin{array}{l}\mathrm{log}\frac{26}{25}\\ =\mathrm{log}\left(1+\frac{1}{25}\right)\\ =\mathrm{log}\left(1+0.04\right)\\ \left|{R}_{2}\right|=\frac{{\left(0.04\right)}^{2}}{2}=0.0008<1{0}^{-3}\\ \mathrm{log}\frac{26}{25}\\ \fallingdotseq 0.040\end{array}$

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, log, Rational, plot

print('1.')

xs = [1.2, 0.9, 1.05, Rational(9, 10), Rational(24, 25), Rational(26, 25)]

for i, x in enumerate(xs):
print(f'({chr(ord("a") + i)})')
for o in [log(x), float(log(x))]:
pprint(o)
print()
print()

x = symbols('x')
p = plot(log(x), show=False, legend=True)

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


C:\Users\...>py sample1.py
1.
(a)
0.182321556793955

0.1823215567939546

(b)
-0.105360515657826

-0.10536051565782628

(c)
0.0487901641694320

0.04879016416943205

(d)
log(9/10)

-0.1053605156578263

(e)
⎛24⎞
log⎜──⎟
⎝25⎠

-0.04082199452025513

(f)
⎛26⎞
log⎜──⎟
⎝25⎠

0.039220713153281295

C:\Users\...>