## 2019年5月25日土曜日

### 数学 - Python - 関連しながら変化する世界 - 簡単な関数 - 分数関数・無理関数 - 簡単な無理方程式・無理不等式(定義域、交点、直線)

1. $\begin{array}{l}x\ge -2,x\ge \frac{4}{3}\\ x+2={\left(3x-4\right)}^{2}\\ 9{x}^{2}-25x+14=0\\ \left(x-2\right)\left(9x-7\right)=0\\ x=2\\ x>2\end{array}$

2. $\begin{array}{l}x\ge -\frac{5}{2},x\ge 0\\ 2x+5=\frac{1}{4}{x}^{2}\\ {x}^{2}-8x-20=0\\ \left(x-10\right)\left(x+2\right)=0\\ x=10\\ x\ge 10\end{array}$

3. $\begin{array}{l}x\le 8,x\ge -2\\ -2\le x\le 8\\ {\left(8-x\right)}^{2}=5x+10\\ {x}^{2}-21x+54=0\\ \left(x-18\right)\left(x-3\right)=0\\ x=3\\ -2\le x\le 3\end{array}$

4. $\begin{array}{l}x\ge -2,x\ge 0\\ x\ge 0\\ \frac{1}{9}{\left(x+2\right)}^{2}=x\\ {x}^{2}-5x+4=0\\ \left(x-1\right)\left(x-4\right)=0\\ x=1,4\\ 0\le x<1,4

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, plot, sqrt, solve, Rational

print('38.')

x = symbols('x', real=True)

ts = [((sqrt(x + 2), (x, -2, 15)), (3 * x - 4, (x, -5, 15))),
((sqrt(2 * x + 5), (x, -Rational(5, 2), 15)), (x / 2, (x, -5, 15))),
((8 - x, (x, -5, 10)), (sqrt(5 * x + 10), (x, -Rational(10, 5), 15))),
(((x + 2) / 3, (x, -5, 15)), (sqrt(x), (x, 0, 15)))]

for i, ((l, _), (r, _)) in enumerate(ts, 1):
print(f'({i})')
pprint(solve(l - r))
print()

fs = []
for a, b in ts:
fs += [a, b]
p = plot(*fs, ylim=(-5, 15), legend=False, show=False)

colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'gray', 'skyblue', 'yellow']

for o, color in zip(p, colors):
o.line_color = color

p.show()
p.save('sample38.png')


C:\Users\...>py sample38.py
38.
(1)
[2]

(2)
[10]

(3)
[3]

(4)
[1, 4]

C:\Users\...>