2019年10月6日日曜日

学習環境

新装版 数学読本2 (松坂 和夫(著)、岩波書店)の第7章(急速・緩慢に変化する関係 - 指数関数・対数関数)、7.3(対数関数の性質)、いくつかの例題および問題の補充の問32の解答を求めてみる。



    1. 9 x + 3 x = 12 3 x 2 + 3 x - 12 = 0 3 x + 4 3 x - 3 = 0 3 x = 3 x = 1

    2. 2 x + 1 + 4 x = 80 2 x 2 + 2 · 2 x - 80 = 0 2 x + 10 2 x - 8 = 0 2 x = 8 x = 3

    3. 4 x - 3 · 2 x + 2 + 32 = 0 2 x 2 - 12 · 2 x + 32 = 0 2 x - 8 2 x - 4 = 0 2 x = 4 , 2 x = 8 x = 2 , x = 3

    4. log 10 x 2 = log 10 x 2 log 10 x 2 - 2 log 10 x = 0 log 10 x log 10 x - 2 = 0 log 10 x = 0 , log 10 x = 2 x = 1 , x = 100

    5. log 2 x = log x 2 log x log 2 = log 2 log x log x 2 = log 2 2 log x = ± log 2 x = 1 2 , 2

    6. log 3 x 3 = log 3 x 4 log 3 x 3 - 4 log 3 x = 0 log 3 x log 3 x 2 - 4 = 0 log 3 x = 0 , ± 2 x = 1 , 1 9 , 9

コード

Python 3

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

print('32.')


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

    def tearDown(self):
        pass

    def test(self):
        x = symbols('x', real=True)
        spam = [9 ** x + 3 ** x - 12,
                2 ** (x + 1) + 4 ** x - 80,
                4 ** x - 3 * 2 ** (x + 2) + 32,
                log(x, 10) ** 2 - log(x ** 2, 10),
                log(x, 2) - log(2, x),
                log(x, 3) ** 3 - log(x ** 4, 3)]
        egg = [[1],
               [3],
               [2, 3],
               [1, 100],
               [Rational(1, 2), 2],
               [Rational(1, 9), 1, 9]]
        for s, t in zip(spam, egg):
            self.assertListEqual(solve(s, x), t)


if __name__ == '__main__':
    main()

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

$ ./sample32.py
32.
.
----------------------------------------------------------------------
Ran 1 test in 1.285s

OK
$ 

0 コメント:

コメントを投稿

関連コンテンツ