2019年8月31日土曜日

学習環境

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



    1. 4 3 + 1 6 = 9 6 = 3 2 4 3 2 = 2 3 = 8

    2. 1 2 - 1 6 + 2 3 = 6 6 = 1 7

    3. 1 6 - 3 2 = - 1 4 16 = 2 4 1 2

    4. 125 8 = 5 3 2 3 = 5 2 3 5 2 2 = 25 4

    5. 4 1 3 12 = 4 4 = 256

    6. 9 16 = 3 4 2 2 · 2 3 - 3 4 = - 1 3 4 - 1 = 4 3

    7. 1 3 + 2 3 + 4 3 + 8 3 = 15 3 = 5 2 5 = 32

    8. 3 3 2 · 3 1 3 · 3 1 6 3 2 + 1 3 + 1 6 = 9 + 2 + 1 6 = 2 3 2 = 9

コード

Python 3

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

print('9.')


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

    def tearDown(self):
        pass

    def test(self):
        spam = [4 ** Rational(4, 3) * 4 ** Rational(1, 6),
                7 ** Rational(1, 2) / 7 ** Rational(1, 6) *
                7 ** Rational(2, 3),
                (16 ** Rational(1, 6)) ** -Rational(3, 2),
                Rational(125, 8) ** Rational(2, 3),
                root(4, 3) ** 12,
                (Rational(9, 16) ** Rational(2, 3)) ** -Rational(3, 4),
                2 ** Rational(1, 3) * 2 ** Rational(2, 3) *
                2 ** Rational(4, 3) * 2 ** Rational(8, 3),
                sqrt(27) * root(3, 3) * root(3, 6)]

        egg = [8, 7, Rational(1, 2), Rational(25, 4), 256, Rational(4, 3), 32,
               9]
        for s, t in zip(spam, egg):
            self.assertEqual(s.factor(), t)


if __name__ == '__main__':
    main()

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

C:\Users\...>py sample9.py
9.
.
----------------------------------------------------------------------
Ran 1 test in 0.016s

OK

C:\Users\...>

0 コメント:

コメントを投稿