2019年9月17日火曜日

学習環境

新装版 数学読本2 (松坂 和夫(著)、岩波書店)の第7章(急速・緩慢に変化する関係 - 指数関数・対数関数)、7.3(対数関数の性質)、対数に関する基本的な等式の問19の解答を求めてみる。



    1. log 6 9 2 + log 6 8 = log 6 9 2 · 8 = log 6 36 = log 6 6 2 = 2 log 6 6 = 2

    2. log 6 24 · 3 12 = 1

    3. log 2 5 10 = log 2 2 - 1 = - 1

    4. log 3 54 · 6 4 = log 3 27 · 3 = log 3 3 4 = 4

    5. log 10 3 3 log 10 3 4 = 3 4

    6. log 10 4 3 · 75 = log 10 4 · 25 = 2

    7. 1 2 log 8 2 + 3 - 2 4 - 3 + 2 - 3 = 1 2 log 8 2 = 1 2 · 1 3 log 8 2 3 = 1 6

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, log, root, sqrt, Rational
from unittest import TestCase, main

print('19.')


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

    def tearDown(self):
        pass

    def test(self):
        a = 2
        L = 5
        M = 6
        N = 7
        u = log(L, a)
        v = log(M, a)
        w = log(N, a)
        spam = [log(Rational(9, 2), 6) + log(8, 6),
                log(24, 6) + log(3, 6) - log(12, 6),
                log(25, 2) / 2 - log(10, 2),
                log(54, 3) + log(6, 3) - 2 * log(2, 3),
                log(27, 10) / log(81, 10),
                log(Rational(4, 3), 10) + 2 * log(sqrt(75), 10),
                log(sqrt(2 + sqrt(3)) - sqrt(2 - sqrt(3)), 8)]
        egg = [2, 1, -1, 4, Rational(3, 4), 2, Rational(1, 6)]
        for i, (s, t) in enumerate(zip(spam, egg)):
            self.assertEqual(float(s), float(t))


if __name__ == '__main__':
    main()

入出力結果(Bash、cmd.exe(コマンドプロンプト)、Terminal、Jupyter(IPython))

C:\Users\...>py sample19.py
19.
.
----------------------------------------------------------------------
Ran 1 test in 0.048s

OK

C:\Users\...>

0 コメント:

コメントを投稿