関数#
関数#
2つの集合の間に対応する規則があるとき、その規則を 関数(function) と呼ぶ。
変数
と書く。この
関数のとりうる範囲を 値域 という。
逆関数#
例:
import numpy as np
import matplotlib.pyplot as plt
a = 1.5
b = 2
def f(x):
return a * x + b
def f_inv(x):
return (x - b) / a
x = np.linspace(0, 1, 10)
y = np.array([f(xi) for xi in x])
fig, ax = plt.subplots(figsize=[4, 2])
ax.plot(x, y, label=r"$f(x)$")
ax.plot(np.array([f_inv(xi) for xi in y]), y, label=r"$f^{-1}(x)$")
ax.legend()
fig.show()
