微分法#
微分係数と導関数#
微分係数#
関数
が存在するとき、
例:
導関数#
微分係数
微分係数は接線の傾き#
微分係数
曲線
Show code cell source
import matplotlib.pyplot as plt
import numpy as np
def f(x):
return x**2
x = np.linspace(0, 5, 50)
fig, ax = plt.subplots(figsize=[3, 2])
ax.plot(x, f(x), color="dimgray")
P = (2, f(2))
ax.scatter(*P, color="dimgray")
ax.text(*P, " P", color="dimgray", va="bottom", ha="center")
Q = (4, f(4))
ax.scatter(*Q, color="dimgray")
ax.text(*Q, " Q", color="dimgray")
R = (Q[0], P[1])
ax.scatter(*R, color="dimgray")
ax.text(*R, " R", color="dimgray")
ax.axvline(R[0], color="dimgray", linestyle=":")
ax.axhline(R[1], color="dimgray", linestyle=":")
ax.set(xlabel="x", ylabel="y")
fig.show()

点Qを曲線に沿って点Pに近づけると、
すなわち、微分係数
たとえば
なので
となっており、
Show code cell source
def f_prime(x):
return 2 * x
fig, axes = plt.subplots(figsize=[4, 3], nrows=2, sharex=True)
x = np.linspace(0, 2.2, 50)
axes[0].plot(x, f(x), label="f(x)")
axes[0].set(ylabel="f(x)")
axes[0].grid(True)
axes[1].plot(x, f_prime(x), label="f'(x)")
axes[1].set(ylabel="f'(x)")
axes[1].grid(True)
fig.show()

微分法の公式#
和と定数倍
微分可能な関数
積の微分
商の微分
導出
商の微分2
import sympy as sp
x = sp.symbols('x')
f = (1 / x) * x**2
sp.diff(f, x)
合成関数の微分
逆関数の微分
微分可能な1価単調連続関数
対数の微分
指数関数の微分
証明
よって逆関数の公式を利用して
例:
方法1:
方法2:
よって
例:
まず、自然対数
逆関数の微分で
n乗の微分
証明(正の整数の指数 について)
等式
を使って、
証明(任意の指数 について)
より、
三角関数の微分#
sin x
証明
cos x
証明
tan x
証明
商の公式を使って
arcsin x
証明
逆関数の微分法より
arccos x
arctan x
連続と微分可能#
関数が
で不連続なら、微分係数は存在しない微分可能なら連続である
ただし、逆は必ずしも成立しない。連続であっても微分可能とは限らない
ライプニッツの公式#
積の微分公式を一般化したもの。
ライプニッツの公式(Leibniz rule)
例:連続だが微分不可能な関数
右微分係数と左微分係数は
であり、確定した微分係数
Show code cell source
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-3, 3, 100)
fig, ax = plt.subplots(figsize=[4,2])
ax.plot(x, abs(x))
ax.set(xlabel="$x$", ylabel=r"$y=|x|$", title=r"$f(x)=|x|$")
fig.show()

対数微分法#
式の両辺の対数をとって微分する方法
両辺を
よって
高次導関数#
導関数
を考えることができて、これを元の関数
一般に
などで表す。このとき、
証明:
を微分すると
よって数学的帰納法により、すべての
例(グラフ)#
Show code cell source
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import ticker
import numdifftools as nd
def f(x):
return x**2
df = nd.Derivative(f, n=1)
ddf = nd.Derivative(f, n=2)
fig, axes = plt.subplots(figsize=[6, 6], nrows=3, sharex=True)
x = np.linspace(-3, 3, 100)
axes[0].plot(x, [f(x_i) for x_i in x])
axes[0].set(ylabel=r"$f(x)$", title=r"$y = f(x) = x^2$")
axes[1].plot(x, df(x).tolist())
axes[1].set(ylabel=r"$f'(x)$")
axes[2].plot(x, ddf(x).tolist())
axes[2].set(ylabel=r"$f''(x)$")
axes[2].yaxis.set_major_formatter(ticker.StrMethodFormatter("{x:.1f}"))
fig.show()

Show code cell source
import numpy as np
import matplotlib.pyplot as plt
import numdifftools as nd
def f(x):
return np.sin(x)
df = nd.Derivative(f, n=1)
ddf = nd.Derivative(f, n=2)
fig, axes = plt.subplots(figsize=[6, 6], nrows=3, sharex=True)
x = np.linspace(-6, 6, 100)
axes[0].plot(x, [f(x_i) for x_i in x])
axes[0].set(ylabel=r"$f(x)$", title=r"$y = f(x) = \sin(x)$")
axes[1].plot(x, df(x).tolist())
axes[1].set(ylabel=r"$f'(x)$")
axes[2].plot(x, ddf(x).tolist())
axes[2].set(ylabel=r"$f''(x)$")
fig.show()

微分#
微分 (differential) は導関数とはまた別に定義される
関数
と定義される。
ライプニッツの公式#
積の微分公式を一般化したもの。
ライプニッツの公式(Leibniz rule)