# 微分方程

## 微分方程解法大全

### 一階常微分方程

#### 變量分離法

##### 例子
###### 冇邊界條件
• ${\displaystyle y'-2x-1=0}$
${\displaystyle {dy \over dx}-2x-1=0}$
${\displaystyle {dy \over dx}=2x+1}$
${\displaystyle dy=(2x+1)\ dx}$
${\displaystyle \int dy=\int (2x+1)\ dx}$
${\displaystyle y=x^{2}+x+C}$（係二次方程）

• ${\displaystyle x+y\ y'=0}$
${\displaystyle x+y\ {dy \over dx}=0}$
${\displaystyle y\ {dy \over dx}=-x}$
${\displaystyle y\ dy=-x\ dx}$
${\displaystyle \int y\ dy=\int -x\ dx}$
${\displaystyle {1 \over 2}y^{2}=-{1 \over 2}x^{2}+C}$
${\displaystyle y^{2}=-x^{2}+C}$
${\displaystyle x^{2}+y^{2}=C}$（係圓方程）
###### 有邊界條件
• ${\displaystyle {\frac {dy}{dx}}+{\frac {1}{2}}y={\frac {3}{2}}}$，其中喺 ${\displaystyle x=0}$ 嘅時候 ${\displaystyle y=4}$
${\displaystyle {\frac {dy}{dx}}+{\frac {1}{2}}y={\frac {3}{2}}}$
${\displaystyle {\frac {dy}{3-y}}={\frac {dx}{2}}}$
${\displaystyle \int _{4}^{y}{\frac {dy}{3-y}}=\int _{0}^{x}{\frac {dx}{2}}}$
${\displaystyle [\ln(y-3)]_{4}^{y}=\left[{\frac {x}{2}}\right]_{0}^{x}}$
${\displaystyle \ln(y-3)-0={\frac {x}{2}}-0}$
${\displaystyle y-3=e^{-{\frac {x}{2}}}}$
${\displaystyle y=e^{-{\frac {x}{2}}}+3}$
• ${\displaystyle {\frac {dy}{dx}}-2xy=x}$，其中喺 ${\displaystyle x=0}$ 嘅時候 ${\displaystyle y=0}$
${\displaystyle {\frac {dy}{dx}}-2xy=x}$
${\displaystyle {\frac {dy}{dx}}=x(2y+1)}$
${\displaystyle {\frac {dy}{2y+1}}=xdx}$
${\displaystyle \int _{0}^{y}{\frac {dy}{2y+1}}=\int _{0}^{x}{xdx}}$
${\displaystyle \left[{\frac {1}{2}}\ln |2y+1|\right]_{0}^{y}=\left[{\frac {x^{2}}{2}}\right]_{0}^{x}}$
${\displaystyle {\frac {1}{2}}\ln |2y+1|={\frac {x^{2}}{2}}}$
${\displaystyle 2y+1=e^{x^{2}}}$
${\displaystyle y={\frac {e^{x^{2}}}{2}}-{\frac {1}{2}}}$

#### 積分因子法

##### 例子
###### 冇邊界條件
• ${\displaystyle y'-3y=4e^{2x}}$
${\displaystyle \mu (x)}$
${\displaystyle =e^{\int (-3)dx}}$
${\displaystyle =e^{-3x}}$
i.e.
${\displaystyle {\frac {d}{dx}}(e^{-3x}y)=e^{-3x}\cdot 4e^{2x}}$
${\displaystyle {\frac {d}{dx}}(e^{-3x}y)=4e^{-x}}$
${\displaystyle \int {{\frac {d}{dx}}(e^{-3x}y)}dx=\int {4e^{-x}}dx}$
${\displaystyle e^{-3x}y=-4e^{-x}+C}$
${\displaystyle y=-4e^{2x}+Ce^{3x}}$
###### 有邊界條件
• ${\displaystyle {\frac {dy}{dx}}-2xy=xe^{-x^{2}}}$，其中喺 ${\displaystyle x=1}$ 嘅時候 ${\displaystyle y=0}$
${\displaystyle \mu (x)}$
${\displaystyle =e^{\int _{1}^{x}(-2x)dx}}$
${\displaystyle =e^{[-x^{2}]_{1}^{x}}}$
${\displaystyle =e^{1-x^{2}}}$
i.e.
${\displaystyle {\frac {d}{dx}}(e^{1-x^{2}}y)=e^{1-x^{2}}\cdot xe^{-x^{2}}}$
${\displaystyle {\frac {d}{dx}}(e^{1-x^{2}}y)=xe^{1-2x^{2}}}$
${\displaystyle \int _{1}^{x}{{\frac {d}{dx}}(e^{1-x^{2}}y)}dx=\int _{1}^{x}{xe^{1-2x^{2}}}dx}$
${\displaystyle \left[e^{1-x^{2}}y\right]_{1}^{x}=\left[-{\frac {1}{4}}e^{1-2x^{2}}\right]_{1}^{x}}$
${\displaystyle e^{1-x^{2}}y={\frac {1}{4}}e^{-1}-{\frac {1}{4}}e^{1-2x^{2}}}$
${\displaystyle y={\frac {1}{4}}e^{x^{2}-2}-{\frac {1}{4}}e^{-x^{2}}}$

#### 全微分方程

##### 例子
###### 冇邊界條件
• ${\displaystyle (3x^{2}y+y^{3})dx+(x^{3}+3xy^{2})dy=0}$

${\displaystyle {\frac {\partial V}{\partial x}}=3x^{2}y+y^{3}}$
${\displaystyle V=x^{3}y+xy^{3}+f(y)}$，其中 ${\displaystyle f(y)}$ 係一個只對應 ${\displaystyle y}$ 嘅函數。

${\displaystyle {\frac {\partial V}{\partial y}}=x^{3}+3xy^{2}}$
${\displaystyle x^{3}+3xy^{2}+{\frac {df}{dy}}=x^{3}+3xy^{2}}$
${\displaystyle {\frac {df}{dy}}=0}$
${\displaystyle f(y)=C}$，其中 ${\displaystyle C}$ 係常數。

• ${\displaystyle {\frac {dy}{dx}}=-{\frac {2xy+5}{x^{2}+8y}}}$
${\displaystyle {\frac {dy}{dx}}=-{\frac {2xy+5}{x^{2}+8y}}}$
${\displaystyle (x^{2}+8y)dy=-(2xy+5)dx}$
${\displaystyle (2xy+5)dx+(x^{2}+8y)dy=0}$

${\displaystyle {\frac {\partial V}{\partial y}}=x^{2}+8y}$
${\displaystyle V=x^{2}y+4y^{2}+f(x)}$，其中 ${\displaystyle f(x)}$ 係一個只對應 ${\displaystyle x}$ 嘅函數。

${\displaystyle {\frac {\partial V}{\partial x}}=2xy+5}$
${\displaystyle 2xy+{\frac {df}{dx}}=2xy+5}$
${\displaystyle {\frac {df}{dx}}=5}$
${\displaystyle f(x)=5x+C}$，其中 ${\displaystyle C}$ 係常數。

##### 全微分方程嘅積分因子

${\displaystyle \mu (x,y)}$ 乘落 ${\displaystyle f(x,y)dx+g(x,y)dy=0}$ 嘅兩邊，我哋有：

${\displaystyle \mu fdx+\mu gdy=0}$

${\displaystyle {\frac {\partial (\mu f)}{\partial y}}={\frac {\partial (\mu g)}{\partial x}}}$

${\displaystyle \mu {\frac {\partial f}{\partial y}}+f{\frac {\partial \mu }{\partial y}}=\mu {\frac {\partial g}{\partial x}}+g{\frac {\partial \mu }{\partial x}}}$

${\displaystyle \mu {\frac {\partial f}{\partial y}}=\mu {\frac {\partial g}{\partial x}}+g{\frac {d\mu }{dx}}}$

${\displaystyle {\frac {d\mu }{dx}}+\left[{\frac {1}{g}}\left({\frac {\partial g}{\partial x}}-{\frac {\partial f}{\partial y}}\right)\right]\mu =0}$

${\displaystyle \mu {\frac {\partial f}{\partial y}}+f{\frac {d\mu }{dy}}=\mu {\frac {\partial g}{\partial x}}}$

${\displaystyle {\frac {d\mu }{dy}}+\left[{\frac {1}{f}}\left({\frac {\partial f}{\partial y}}-{\frac {\partial g}{\partial x}}\right)\right]\mu =0}$

###### 冇邊界條件
• ${\displaystyle (3xy+y^{2})dx+(x^{2}+xy)dy=0}$

${\displaystyle {\frac {1}{N}}\left({\frac {\partial M}{\partial y}}-{\frac {\partial N}{\partial x}}\right)}$

${\displaystyle ={\frac {1}{x^{2}+xy}}[(3x+2y)-(2x+y)]}$

${\displaystyle ={\frac {1}{x^{2}+xy}}(x+y)}$

${\displaystyle ={\frac {1}{x}}}$

${\displaystyle {\frac {d\mu }{dx}}={\frac {\mu }{x}}}$

${\displaystyle {\frac {d\mu }{\mu }}={\frac {dx}{x}}}$

${\displaystyle \int {\frac {d\mu }{\mu }}=\int {\frac {dx}{x}}}$

${\displaystyle \ln \mu =\ln x+C}$，其中 ${\displaystyle C}$ 係常數。

${\displaystyle \ln \mu =\ln x}$

${\displaystyle \mu =x}$

${\displaystyle x(3xy+y^{2})dx+x(x^{2}+xy)dy=0}$

${\displaystyle (3x^{2}y+xy^{2})dx+(x^{3}+x^{2}y)dy=0}$

${\displaystyle V(x,y)=x^{3}y+{\frac {x^{2}y^{2}}{2}}+C}$，其中 ${\displaystyle C}$ 係常數。

#### 一階齊次方程

${\displaystyle {\frac {dy}{dx}}=v+x{\frac {dv}{dx}}}$

${\displaystyle v+x{\frac {dv}{dx}}=f(v)}$

${\displaystyle {\frac {dv}{dx}}={\frac {f(v)-v}{x}}}$

##### 例子
###### 冇邊界條件
• ${\displaystyle {\frac {dy}{dx}}={\frac {y^{2}+2xy}{x^{2}}}}$

${\displaystyle v+x{\frac {dv}{dx}}=v^{2}+2v}$

${\displaystyle {\frac {dv}{dx}}={\frac {v(v+1)}{x}}}$

${\displaystyle {\frac {dv}{v(v+1)}}={\frac {dx}{x}}}$

${\displaystyle \left({\frac {1}{v}}-{\frac {1}{v+1}}\right)dv={\frac {dx}{x}}}$

${\displaystyle \int \left({\frac {1}{v}}-{\frac {1}{v+1}}\right)dv=\int {\frac {dx}{x}}}$

${\displaystyle \ln |v|-\ln |v+1|=\ln |x|+C}$，其中 ${\displaystyle C}$ 係常數。

${\displaystyle {\frac {v}{v+1}}=cx}$，其中 ${\displaystyle c=e^{C}}$

${\displaystyle cxv+cx=v}$

${\displaystyle (cx-1)v=-cx}$

${\displaystyle v={\frac {cx}{1-cx}}}$

${\displaystyle y=\left({\frac {cx}{1-cx}}\right)x}$

${\displaystyle y={\frac {cx^{2}}{1-cx}}}$

### 二階常微分方程

#### 特徵方程法

##### 例子
###### 冇邊界條件
• ${\displaystyle {\frac {d^{2}y}{dx^{2}}}-6{\frac {dy}{dx}}+8y=0}$

${\displaystyle r^{2}-6r+8=0}$
${\displaystyle (r-2)(r-4)=0}$
${\displaystyle r=2}$ 或者 ${\displaystyle r=4}$

###### 有邊界條件
• ${\displaystyle {\frac {d^{2}y}{dx^{2}}}-2{\frac {dy}{dx}}+3y=0}$${\displaystyle y(0)=1}$${\displaystyle y'(0)=0}$

${\displaystyle r^{2}-2r+3=0}$
${\displaystyle r={\frac {-(-2)\pm {\sqrt {(-2)^{2}-4(1)(3)}}}{2(1)}}}$
${\displaystyle r=1\pm {\sqrt {2}}i}$

{\displaystyle {\begin{aligned}&1=A'e^{0}\cos {\sqrt {2}}(0)+B'e^{0}\sin {\sqrt {2}}(0)\\&0=A'e^{0}\cos {\sqrt {2}}(0)-A'e^{0}\sin {\sqrt {2}}(0)+B'e^{0}\sin {\sqrt {2}}(0)+B'e^{0}\cos {\sqrt {2}}(0)\end{aligned}}}

#### 微分算子法

${\displaystyle a{\frac {d^{2}y}{dx^{2}}}+b{\frac {dy}{dx}}+cy=0}$

${\displaystyle {\frac {d^{2}y}{dx^{2}}}+{\frac {b}{a}}{\frac {dy}{dx}}+{\frac {c}{a}}y=0}$

${\displaystyle {\frac {d^{2}y}{dx^{2}}}-(r_{1}+r_{2}){\frac {dy}{dx}}+r_{1}r_{2}y=0}$

${\displaystyle {\frac {d}{dx}}\left({\frac {dy}{dx}}\right)-(r_{1}+r_{2}){\frac {dy}{dx}}+r_{1}r_{2}y=0}$

${\displaystyle {\frac {d}{dx}}\left({\frac {d}{dx}}\right)y-(r_{1}+r_{2})\left({\frac {d}{dx}}\right)y+r_{1}r_{2}y=0}$

${\displaystyle \left({\frac {d}{dx}}\right)^{2}y-(r_{1}+r_{2})\left({\frac {d}{dx}}\right)y+r_{1}r_{2}y=0}$

${\displaystyle D^{2}y-(r_{1}+r_{2})Dy+r_{1}r_{2}y=0}$

${\displaystyle [D^{2}-(r_{1}+r_{2})D+r_{1}r_{2}]y=0}$

${\displaystyle (D-r_{1})(D-r_{2})y=(D-r_{2})(D-r_{1})y=0}$

${\displaystyle (D-r_{1})u=0}$

${\displaystyle \left({\frac {d}{dx}}-r_{1}\right)u=0}$

${\displaystyle {\frac {du}{dx}}-r_{1}u=0}$

${\displaystyle {\frac {du}{dx}}=r_{1}u}$

${\displaystyle {\frac {du}{u}}=r_{1}dx}$

${\displaystyle \int {\frac {du}{u}}=\int r_{1}dx}$

${\displaystyle \ln |u|+C'=r_{1}x+C''}$，其中 ${\displaystyle C'}$ 同埋 ${\displaystyle C''}$ 都係常數。

${\displaystyle \ln |u|=r_{1}x+(C''-C')}$

${\displaystyle |u|=e^{r_{1}x+(C''-C')}}$

${\displaystyle |u|=e^{C''-C'}\cdot e^{r_{1}x}}$

${\displaystyle u=\pm e^{C''-C'}\cdot e^{r_{1}x}}$

${\displaystyle u=(D-r_{2})y}$

${\displaystyle Ce^{r_{1}x}=\left({\frac {d}{dx}}-r_{2}\right)y}$

${\displaystyle {\frac {dy}{dx}}-r_{2}y=Ce^{r_{1}x}}$

${\displaystyle \mu }$

${\displaystyle =e^{\int -r_{2}dx}}$

${\displaystyle =e^{-r_{2}x}}$

${\displaystyle {\frac {d}{dx}}\left(e^{-r_{2}x}y\right)=Ce^{(r_{1}-r_{2})x}}$

${\displaystyle e^{-r_{2}x}y=\int Ce^{(r_{1}-r_{2})x}dx}$

${\displaystyle e^{-r_{2}x}y=\int Ce^{(r_{1}-r_{2})x}dx}$

${\displaystyle e^{-r_{2}x}y={\frac {C}{r_{1}-r_{2}}}e^{(r_{1}-r_{2})x}+C_{2}}$，其中 ${\displaystyle C_{2}}$ 係常數。

${\displaystyle y={\frac {C}{r_{1}-r_{2}}}e^{r_{1}x}+C_{2}e^{r_{2}x}}$

${\displaystyle y=C_{1}e^{r_{1}x}+C_{2}e^{r_{2}x}}$