## 2019年5月30日木曜日

### 数学 - Python - 関連しながら変化する世界 - 簡単な関数 - 分数関数・無理関数 - 逆関数(定義域と値域)

1. 逆関数は、

$\begin{array}{l}x=3y-2\\ y=\frac{x}{3}+\frac{2}{3}\end{array}$

定義域は 実数全体。

2. $\begin{array}{l}x=\frac{1}{3}y+2\\ y=3x-6\\ x\in \text{ℝ}\end{array}$

3. $\begin{array}{l}x=\frac{2}{y}-1\\ xy=2-y\\ y=\frac{2}{x+1}\\ \left\{x\in \text{ℝ}|x\ne 1\right\}\end{array}$

4. $\begin{array}{l}x=\frac{y-1}{y}\\ xy=y-1\\ y=-\frac{1}{x-1}\\ \left\{x\in \text{ℝ}|x\ne 1\right\}\end{array}$

5. $\begin{array}{l}x=\frac{1}{2-y}\\ 2x-xy=1\\ y=\frac{2x-1}{x}\\ y=-\frac{1}{x}+2\\ \left\{x\in \text{ℝ}|x>0\right\}\end{array}$

6. $\begin{array}{l}x=4{y}^{2}\\ y=\frac{1}{2}\sqrt{x}\\ \left\{x\in \text{ℝ}|x\ge 0\right\}\end{array}$

7. $\begin{array}{l}x=-{y}^{2}+2\\ {y}^{2}=2-x\\ y=-\sqrt{2-x}\\ \left\{x\in \text{ℝ}|x\le 2\right\}\end{array}$

8. $\begin{array}{l}x=-\sqrt{y}\\ y={x}^{2}\\ \left\{x\in \text{ℝ}|x\le 0\right\}\end{array}$

9. $\begin{array}{l}x=\sqrt{y+4}\\ y={x}^{2}-4\\ \left\{x\in \text{ℝ}|x\ge 0\right\}\end{array}$

10. $\begin{array}{l}x=-\sqrt{1-y}\\ {x}^{2}=1-y\\ y=-{x}^{2}+1\\ \left\{x\in \text{ℝ}|x\le 0\right\}\end{array}$

コード

Python 3

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

print('41.')

x, y = symbols('x, y', real=True)
fs = [3 * x - 2,
x / 3 + 2,
2 / x - 1,
(x - 1) / x,
1 / (2 - x),
4 * x ** 2,
-x ** 2 + 2,
- sqrt(x),
sqrt(x + 4),
-sqrt(1 - x)]

for i, f in enumerate(fs, 1):
print(f'({i})')
pprint(solve(y - f, x))
print()

p = plot(*fs, ylim=(-10, 10),
legend=True, show=False)

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

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

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


C:\Users\...>py sample41.py
41.
(1)
⎡y   2⎤
⎢─ + ─⎥
⎣3   3⎦

(2)
[3⋅y - 6]

(3)
⎡  2  ⎤
⎢─────⎥
⎣y + 1⎦

(4)
⎡ -1  ⎤
⎢─────⎥
⎣y - 1⎦

(5)
⎡    1⎤
⎢2 - ─⎥
⎣    y⎦

(6)
⎡-√y   √y⎤
⎢────, ──⎥
⎣ 2    2 ⎦

(7)
⎡   _______    _______⎤
⎣-╲╱ 2 - y , ╲╱ 2 - y ⎦

(8)
[]

(9)
⎡ 2    ⎤
⎣y  - 4⎦

(10)
[]

C:\Users\...>