2019年10月4日金曜日

数学 - Python - 急速・緩慢に変化する関係 - 指数関数・対数関数 - 対数関数の性質 - 常用対数 - 常用対数表、底の変換公式

1. $\begin{array}{l}{\mathrm{log}}_{2}10\\ =\frac{{\mathrm{log}}_{10}10}{{\mathrm{log}}_{10}2}\\ \fallingdotseq \frac{1}{0.3010}\\ \fallingdotseq 0.30\end{array}$

2. $\begin{array}{l}{\mathrm{log}}_{3}4\\ =2{\mathrm{log}}_{3}2\\ \fallingdotseq 2·0.63\\ =1.26\end{array}$

3. $\begin{array}{l}{\mathrm{log}}_{8}3\\ =\frac{{\mathrm{log}}_{10}3}{{\mathrm{log}}_{10}8}\\ =\frac{{\mathrm{log}}_{10}3}{3{\mathrm{log}}_{10}2}\\ \fallingdotseq \frac{1}{3}·\frac{0.4771}{0.3010}\\ \fallingdotseq 0.53\end{array}$

4. $\begin{array}{l}{\mathrm{log}}_{5}64\\ ={\mathrm{log}}_{5}{2}^{6}\\ =6{\mathrm{log}}_{5}2\\ =\frac{6{\mathrm{log}}_{10}2}{{\mathrm{log}}_{10}5}\\ \fallingdotseq \frac{6·0.3010}{0.6990}\\ \fallingdotseq 2.58\end{array}$

コード

Python 3

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import log

print('31.')

class MyTestCase(TestCase):
def setUp(self):
pass

def tearDown(self):
pass

def test(self):
spam = [log(10, 2),
log(4, 3),
log(3, 8),
log(64, 5)]
egg = [3.32, 1.26, 0.53, 2.58]
for s, t in zip(spam, egg):
self.assertEqual(round(float(s), 2), t)

if __name__ == '__main__':
main()


$./sample31.py 31. . ---------------------------------------------------------------------- Ran 1 test in 0.008s OK$