# 微分方程

## 微分方程解法大全

### 變量分離法

#### 例子

##### 冇邊界條件
• ${\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}=[{\frac {x}{2}}]_{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 [{\frac {1}{2}}\ln |2y+1|]_{0}^{y}=[{\frac {x^{2}}{2}}]_{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 [e^{1-x^{2}}y]_{1}^{x}=[-{\frac {1}{4}}e^{1-2x^{2}}]_{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 {\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}}}