2019年10月6日日曜日

数学 - Python - 急速・緩慢に変化する関係 - 指数関数・対数関数 - 対数関数の性質 - いくつかの例題および問題の補充 - 方程式の解

1. $\begin{array}{l}{9}^{x}+{3}^{x}=12\\ {\left({3}^{x}\right)}^{2}+{3}^{x}-12=0\\ \left({3}^{x}+4\right)\left({3}^{x}-3\right)=0\\ {3}^{x}=3\\ x=1\end{array}$

2. $\begin{array}{l}{2}^{x+1}+{4}^{x}=80\\ {\left({2}^{x}\right)}^{2}+2·{2}^{x}-80=0\\ \left({2}^{x}+10\right)\left({2}^{x}-8\right)=0\\ {2}^{x}=8\\ x=3\end{array}$

3. $\begin{array}{l}{4}^{x}-3·{2}^{x+2}+32=0\\ {\left({2}^{x}\right)}^{2}-12·{2}^{x}+32=0\\ \left({2}^{x}-8\right)\left({2}^{x}-4\right)=0\\ {2}^{x}=4,{2}^{x}=8\\ x=2,x=3\end{array}$

4. $\begin{array}{l}{\left({\mathrm{log}}_{10}x\right)}^{2}={\mathrm{log}}_{10}{x}^{2}\\ {\left({\mathrm{log}}_{10}x\right)}^{2}-2{\mathrm{log}}_{10}x=0\\ {\mathrm{log}}_{10}x\left({\mathrm{log}}_{10}x-2\right)=0\\ {\mathrm{log}}_{10}x=0,{\mathrm{log}}_{10}x=2\\ x=1,x=100\end{array}$

5. $\begin{array}{l}{\mathrm{log}}_{2}x={\mathrm{log}}_{x}2\\ \frac{\mathrm{log}x}{\mathrm{log}2}=\frac{\mathrm{log}2}{\mathrm{log}x}\\ {\left(\mathrm{log}x\right)}^{2}={\left(\mathrm{log}2\right)}^{2}\\ \mathrm{log}x=±\mathrm{log}2\\ x=\frac{1}{2},2\end{array}$

6. $\begin{array}{l}{\left({\mathrm{log}}_{3}x\right)}^{3}={\mathrm{log}}_{3}{x}^{4}\\ {\left({\mathrm{log}}_{3}x\right)}^{3}-4{\mathrm{log}}_{3}x=0\\ \left({\mathrm{log}}_{3}x\right)\left({\left({\mathrm{log}}_{3}x\right)}^{2}-4\right)=0\\ {\mathrm{log}}_{3}x=0,±2\\ x=1,\frac{1}{9},9\end{array}$

コード

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()


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