내용
적분방법
어떤 것을 적분하기 위해서는 그들을 적분할 수 있는 형태로 재구성하는 것으로부터 시작합니다. 이러한 재구성에는 다양한 방법들이 적용됩니다.
부분적분
식 1과 같이 미분의 곱법칙을 적분에 적용할 수 있습니다.
$$\begin{align}\tag{1}d(uv) &= u·dv + v·du\\ u·dv &= d(uv) - v·du\\ ∫u·dv &= \int d(uv) - \int v\,du\\ &= uv - ∫v·du + C\end{align}$$식 1에서 u는 정상함수, dv는 미분된 함수를 나타냅니다.
식 1은 식 2와 같이 부분적분 공식으로 정리할 수 있습니다.
부분 적분의 몇 가지 예제들을 계산해 봅니다.
예)
함수 w·sin(w)의 경우 직접 적분하기는 어렵지만 두 식의 곱으로 구성되어 있으므로 부분 적분을 적용할 수 있습니다. 즉, w를 원함수 u로 하고 sin(w)를 미분된 함수 dv라고 한다면 다음과 같이 전개할 수 있습니다.
위 부분적분의 과정에 따라 코드를 작성해 보면 다음과 같습니다.
import numpy as np from sympy import *
w = symbols("w") y=w*sin(w) u=w dv=sin(w) uInt_dv=u*integrate(dv, w) int_vdu=integrate(integrate(dv, w)*diff(u, w)) re=uInt_dv-int_vdu re$\color{navy}{- w \cos{\left(w \right)} + \sin{\left(w \right)}}$
위 결과는 함수 y를 직접 적분한 것과 같아야 합니다.
integrate(y, w)$\color{navy}{ - w \cos{\left(w \right)} + \sin{\left(w \right)}}$
예)
$\displaystyle \int xe^x\, dx$?
$$\begin{align}
u = x,&\quad dv = e^x\\
v &= \int e^x \, dx \\
&= e^x\\
\int x·e^x\, dx &= x·e^x - \int e^x\, dx\\
&= x·e^x - e^x + C
\end{align}$$
x = symbols("x") y=x*exp(x) u=x dv=exp(x) uInt_dv=u*integrate(dv, x) int_vdu=integrate(integrate(dv, x)*diff(u, x)) re=uInt_dv-int_vdu re$\color{navy}{x e^{x} - e^{x}}$
integrate(y, x)$\color{navy}{ \left(x - 1\right) e^{x}}$
예)
$\displaystyle \cos^2(\theta)\, d\theta$?
$$\begin{align}
\cos(\theta) = u,&\quad \cos(\theta) = dv \quad \rightarrow \sin(\theta) = v\\
\int \cos^2(\theta)\, d\theta &= \cos(\theta)\sin(\theta) + \int \sin^2(\theta) \,d\theta\\
&= \frac{\sin(2\theta)}{2} + \int (1-\cos^2(\theta))\, d\theta\\
&= \frac{\sin(2\theta)}{2} + \int d\theta - \int \cos^2(\theta)\, d\theta\\
2\int \cos^2(\theta)\, d\theta &= \frac{\sin(2\theta)}{2} + \theta\\
\int \cos^2(\theta)\, d\theta &= \frac{\sin(2\theta)}{4} + \frac{\theta}{2}+ C\\
\because \sin(\theta+\theta) &= 2\sin(\theta)\cos(\theta)
\end{align}$$
theta=symbols("theta") y=cos(theta)**2 u=cos(theta) dv=cos(theta) uInt_dv=u*integrate(dv, theta) int_vdu=integrate(integrate(dv, theta)*diff(u, theta), theta) uInt_dv-int_vdu$\color{navy}{ \frac{\theta}{2} + \frac{\sin{\left(\theta \right)} \cos{\left(\theta \right)}}{2}}$
integrate(y, theta)$\color{navy}{ \frac{\theta}{2} + \frac{\sin{\left(\theta \right)} \cos{\left(\theta \right)}}{2}}$
예)
$\int x^2\sin(x)\,dx$?
$$\begin{align}
&u = x^2, \quad v = \sin(x)dx\\
&\begin{aligned}\int x^2\sin(x) \,dx & = -x^2\cos(x) + 2\int x \cdot \cos(x) \,dx\\
&= -x^2\cos(x) +2\left[x\sin(x)-\int \sin(x)\, dx \right]\\
&=-x^2\cos(x) +2x\sin(x)+2\cos(x)+C\end{aligned}
\end{align}$$
위 식의 $\displaystyle \int x \cos(x)$의 계산은 부분 적분을 다시 적용합니다.
x= symbols("x") y=x**2*sin(x) u=x**2 dv=sin(x) uInt_dv=u*integrate(dv, x) int_vdu=integrate(integrate(dv, x)*diff(u, x)) re=uInt_dv-int_vdu re$\color{navy}{ - x^{2} \cos{\left(x \right)} + 2 x \sin{\left(x \right)} + 2 \cos{\left(x \right)}}$
integrate(y, x)$\color{navy}{ - x^{2} \cos{\left(x \right)} + 2 x \sin{\left(x \right)} + 2 \cos{\left(x \right)}}$
예)
$\displaystyle \int \sqrt{1-x^2}\,dx$?
$$\begin{align}
\int \sqrt{1-x^2}\,dx &= \int \frac{1-x^2}{\sqrt{1-x^2}} dx\\
&= \int \frac{1}{\sqrt{1-x^2}} \,dx -\int \frac{x^2}{\sqrt{1-x^2}}\,dx
\end{align}$$
위 결과의 우항의 첫 번째 항은 y=arcsin(x)의 미분 결과입니다. 위 결과는 다음과 같이 삼각함수로 치환하여 적분할 수 있습니다.
다음 함수의 적분에서 함수의 분모는 반지름이 1인 반원의 식과 같습니다.
$$\int \frac{1}{\sqrt{1-x^2}}\,dx$$import matplotlib.pyplot as plt
x=np.linspace(-1, 1, 100) y=np.sqrt(1-x**2) plt.figure(dpi=100) plt.plot(x, y, label=r"$y=\sqrt{1-x^2}$") plt.scatter(0.8, np.sqrt(1-0.8**2), label="(0.8, 0.6)") plt.arrow(0, 0, 0.8, np.sqrt(1-0.8**2)) plt.arrow(0, 0, 0.8, 0) plt.arrow(0.8, 0, 0, np.sqrt(1-0.8**2)) plt.legend(loc="upper left") plt.text(0.72, 0.5, r"$\mathbf{\theta}$") plt.text(0.5, 0.43, 1) plt.text(-0.5, 0.5, r"$\mathbf{\sin(\theta)=\frac{x}{1}}$") plt.text(-0.5, 0.38, r"$\mathbf{\cos(\theta)d\theta=dx}$") plt.show()
그러므로 다음과 같이 치환에 의해 적분을 실행할 수 있습니다.
$$\begin{align} \int \frac{1}{\sqrt{1-x^2}}\,dx&=\int \frac{1}{\sqrt{1-\sin^2(\theta)}}\cos(\theta)\,d\theta\\ &=\int \frac{1}{\cos(\theta)}\cos(\theta)\,dx\\ &=\theta\\ &=\sin^{-1}(x) \end{align}$$x=symbols("x") diff(asin(x))$\color{navy}{ \frac{1}{\sqrt{1 - x^{2}}}}$
위 결과들을 적용하면 결과는 다음과 같습니다.
$$\int \sqrt{1-x^2}\,dx = \frac{x\sqrt{1-x^2}}{2} +\frac{1}{2}\arcsin(x) + C$$y=(sqrt(1-x**2)) integrate(y,x)$\color{navy}{ \frac{x \sqrt{1 - x^{2}}}{2} + \frac{\operatorname{asin}{\left(x \right)}}{2}}$
치환적분
이 방법은 치환 미분과 같은 방식으로 이루어집니다. 즉, 적분 대상을 적분인자와 같은 형식으로 치환하여 계산하는 방법입니다.
예)
$\int \sqrt{3+x}\,dx$에서 3+x를 u로 치환하면 간단한 형태로 변환할 수 있습니다.
x= symbols("x") y=(sqrt(3+x)) integrate(y,x)$\color{navy}{ \frac{2 \left(x + 3\right)^{\frac{3}{2}}}{3}}$
예)
$\displaystyle \int \frac{1}{e^x+\frac{1}{e^x}}\,dx$?
위 전개 과정에서 $\displaystyle \frac{1}{u^2+1}$은 $\displaystyle \tan^{-1}(x)$의 미분 결과입니다.
dx, x, u= symbols("dx, x, u") eq1=Eq(u, exp(x)) diff(eq1, x)$\color{navy}{ \frac{\partial}{\partial x} u = e^{x}}$
u1=exp(x) y=(u*(u+1/u))**(-1) y$\color{navy}{ \frac{1}{u \left(u + \frac{1}{u}\right)}}$
integrate(y, u)$\color{navy}{ \operatorname{atan}{\left(u \right)}}$
예)
$\displaystyle \left(x^2+2x+3\right)^{-1}$의 적분?
$$\begin{align}
x+1 = u,&\quad dx = du\\
\int \frac{1}{x^2+2x+3}\,dx &= \int \frac{1}{x^2+2x+1+2}\,dx\\
&= \int \frac{1}{(x+1)^2+(\sqrt{2})^2}\, dx \\
&= \int \frac{1}{u^2+(\sqrt{2})^2}\, du
\end{align}$$
위 전개 과정의 마지막 식은 다음의 함수 y의 미분 결과와 같습니다. 역으로 그 마지막 식의 적분 결과는 다음 코드와 같습니다.
$$\begin{align} y &= \frac{1}{a} \tan^{-1}(u)\\ \frac{dy}{du} &= \frac{1}{u^2 + a^2} \end{align}$$x=symbols("x") y= 1/(x**2+2*x+3) integrate(y, x)$\color{navy}{ \frac{\sqrt{2} \operatorname{atan}{\left(\frac{\sqrt{2} x}{2} + \frac{\sqrt{2}}{2} \right)}}{2}}$
위 예제들은 이항 및 삼각함수 표현에 적용할 수 있는 특수한 형태이며, 알려진 적분 결과로 전환된 것입니다. 즉, 분모의 통분 및 인수 분해는 특별한 경우에 적용 할 수 있는 방법으로 프로그밍이 아닌 직접 계산을 실행할 경우 익숙해지려면 많은 연습이 필요합니다. 또한 적분의 영역을 복소수 영역으로 확장한다면 더 복잡한 결과를 얻을수 있습니다. 예를 들어 이 예의 x2 + 2x + 3은 복소수 부분을 포함한다면 다음과 같이 인수분해 됩니다.
이 식에서 x의 해를 계산하기 위해 다음 코드에서 roots()
함수를 적용하였습니다.
roots(x**2+2*x+3)
{-1 - sqrt(2)*I: 1, -1 + sqrt(2)*I: 1}
이 결과를 적용하여 위 함수 y를 부분분수로 분해하여 적분할 수 있습니다.
y=1/(2*sqrt(2)*I)*(1/(x+1 + sqrt(2)*I)+1/(x+1- sqrt(2)*I)) integrate(y, x)$\color{navy}{ - \frac{\sqrt{2} i \log{\left(x^{2} + 2 x + 3 \right)}}{4}}$
다른 수학 계산과 같이 적분 역시 계산의 한계 조건 등에 따라 다양한 답들이 존재할 수 있으며 무한대 또는 0으로 나누어지는 경우에는 명확한 답을 도출할 수 없습니다. 즉, 모든 경우에 사용할 수 있는 방법은 없습니다. 그러므로 적분 실행 시 이러한 조건들을 정해놓는 것이 중요합니다.
예)
$\displaystyle y=\frac{1}{a^2-x^2}$를 적분합니다.
이 함수는 부분 분수로 전환하여 시행할 수 있습니다.
a, x=symbols("a, x") y=1/(a**2-x**2) y$\color{navy}{ \frac{1}{a^{2} - x^{2}}}$
#부분분수 y1=apart(y, x) y1$\color{navy}{ \frac{1}{2 a \left(a + x\right)} - \frac{1}{2 a \left(- a + x\right)}}$
#부분분수를 적분 simplify(integrate(y1, x))$\color{navy}{ \frac{- \log{\left(- a + x \right)} + \log{\left(a + x \right)}}{2 a}}$
#부분분수 적용없이 직접 적분 simplify(integrate(y, x))$\color{navy}{ \frac{- \log{\left(- a + x \right)} + \log{\left(a + x \right)}}{2 a}}$
댓글
댓글 쓰기