指数関数¶
(英語だとtheがつくかどうかで底の違いを表現する。日本語だとややこしいが、標準的な指数関数はを底とする指数関数である)
Source
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-2, 2, 100)
y = np.array([np.exp(xi) for xi in x])
fig, ax = plt.subplots(figsize=[4, 2])
ax.plot(x, y, label=r"$\exp(x)$")
ax.set(xlabel="x", ylabel="y")
ax.axhline(color="gray")
ax.axvline(color="gray")
ax.legend()
fig.show()
のとき、
のとき、
のとき、
を有限の範囲でいくつか試すと以下のようになる
x = 1
for n in range(1, 6):
e = (1 + (x / n))**n
print(f"{n=}, {e=:.3f}")n=1, e=2.000
n=2, e=2.250
n=3, e=2.370
n=4, e=2.441
n=5, e=2.488
Source
import numpy as np
import matplotlib.pyplot as plt
N = np.linspace(1, 100, 101)
E = [(1 + (x / n))**n for n in N]
fig, ax = plt.subplots(figsize=[4, 2])
ax.plot(N, E)
ax.set(
xlabel="n",
ylabel=r"$(1 + \frac{x}{n})^n$",
title=r"$(1 + \frac{x}{n})^n, x=1$",
yticks=[2, np.exp(1),3],
)
ax.axhline(np.exp(1), color="gray")
ax.axvline(color="gray")
fig.show()
指数(関数)の基本的性質(指数法則)¶
例: は?
とを乗じればとなる。
なのでとなる。一般にも同様。
例: は?
とを乗じればとなる。
なので
を0.01増やすとが1%増える¶
この誤差はが大きくなるにつれて大きくなる
Source
import numpy as np
import pandas as pd
x = np.linspace(0, 0.1, 11)
y = np.exp(x)
display(pd.DataFrame(dict(x=x, y=y)).round(3))Loading...
Source
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 0.5, 0.01)
y = np.exp(x)
fig, axes = plt.subplots(figsize=[5, 3], nrows=2, sharex=True)
axes[0].plot(x, 1+x, label=r"$1 + x$")
axes[0].plot(x, y, label=r"$exp(x)$")
axes[0].legend()
axes[1].plot(x, y - (1+x), label=r"difference: $exp(x) - (1 + x)$")
axes[1].legend()
axes[0].set(title=r"$exp(x) \approx 1 + x$")
plt.show()
Source
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0.1, 5, 100)
y = np.array([np.log(xi) for xi in x])
fig, ax = plt.subplots(figsize=[4, 2])
ax.axhline(color="gray")
ax.axvline(color="gray")
ax.plot(x, y, label=r"$\log(x)$")
ax.set(xlabel="x", ylabel="y")
ax.legend()
fig.show()
元本が2倍になる年数は¶
import numpy as np
np.log10(2) / np.log10(1.05)14.206699082890461