2019年9月9日月曜日

学習環境

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



    1. 3 2 = x x = 9

    2. x = 4 · 1 = 1 4

    3. x = 8 1 1 4 = 3 4 1 4 = 3

    4. x = 0.2 - 2 = 1 5 - 2 = 25

    5. x 2 = 25 x 2 = 5 2 x = 5

    6. x - 3 = 1 1000 = 1 0 - 3 x = 10

    7. x 4 = 2 8 x 4 = 2 2 4 x = 4

    8. x - 2 = 4 x - 2 = 2 2 x - 2 = 1 2 - 2 x - 2 = 1 2 - 2 x = 1 2

    9. x 1 4 = 3 = 3 1 2 = 3 2 1 4 x = 9

コード

Python 3

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

print('14.')


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

    def tearDown(self):
        pass

    def test(self):
        x = symbols('x')
        eqs = [log(x, 3) - 2,
               log(x, 4) + 1,
               log(x, 81) - Rational(1, 4),
               log(x, Rational(1, 5)) + 2,
               log(25, x) - 2,
               log(Rational(1, 1000), x) + 3,
               log(256, x) - 4,
               log(4, x) + 2,
               log(sqrt(3), x) - Rational(1, 4)]
        egg = [9,
               Rational(1, 4),
               3,
               25,
               5,
               10,
               4,
               Rational(1, 2),
               9]

        for s, t in zip(eqs, egg):
            self.assertEqual(solve(s), [t])


if __name__ == '__main__':
    main()

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

C:\Users\...>py sample14.py
14.
.
----------------------------------------------------------------------
Ran 1 test in 0.491s

OK

C:\Users\...>

0 コメント:

コメントを投稿