기본 콘텐츠로 건너뛰기

[matplotlib] 등고선(Contour)

극한의 특성과 계산

극한의 특성

$\lim_{x \to a}f(x), \;  \lim_{x \to a}g(x)$ 그리고 상수(constant) c사이에 다음 관계들이 성립합니다.

import numpy as np
import pandas as pd
from sympy import *
import matplotlib.pyplot as plt
x=symbols("x")
f=x**2+3*x
g=x**3+4*x+5
c=3
a=2
f
$\quad \color{blue}{x^{2} + 3 x}$
g
$\quad \color{blue}{x^{3} + 4 x + 5}$

1) $\displaystyle \lim_{x \to a}cf(x)=c\lim_{x \to a}f(x)$

limit(c*f, x, a)
30
c*limit(f, x, a)
30

2) $\displaystyle \lim_{x \to a}[f(x) \pm g(x)]=\lim_{x \to a}f(x) \pm \lim_{x \to a}g(x)$

limit(f+g, x, a)
31
limit(f, x, a)+limit(g, x, a)
31

3) $\displaystyle \lim_{x \to a}[f(x) g(x)]=\lim_{x \to a}f(x)  \lim_{x \to a}g(x)$

limit(f*g, x, a)
210
limit(f, x, a)*limit(g, x, a)
210

4) $\displaystyle \lim_{x \to a}\frac{f(x)}{g(x)}=\frac{\lim_{x \to a}f(x)}{\lim_{x \to a}g(x)}, \quad \lim_{x \to a}g(x)\neq 0$

limit(f/g, x, a)
$\quad \color{blue}{\displaystyle \frac{1}{21}}$
limit(f, x, a)/limit(g, x, a)
$\quad \color{blue}{\displaystyle \frac{1}{21}}$

5) $\lim_{x \to a}[f(x)]^n=[\lim_{x \to a}f(x)]^n, \quad n \in\;$실수

limit(f**c, x, a)
1000
limit(f, x, a)**c
1000

6) 5)와 같은 특성으로 n 제곱근에서도 성립합니다.

$$\lim_{x \to a}\sqrt[n]{f(x)}=\sqrt[n]{\lim_{x \to a}f(x)}, \quad n \in\; \text{실수}$$
N(limit(f**(1/c), x, a), 4)
2.154
N((limit(f, x, a))**(1/c), 4)
2.154

7) 실수의 극한값은 그 자신이 됩니다.

$$\lim_{x \to a} c = c$$
limit(c, x, a)
3

8)$\displaystyle \lim_{x \to a}x=a$
a=2에서의 극한값은 2입니다.<\p>

f=x
a=np.r_[np.linspace(1.9, 1.999, 5), np.linspace(2.001, 2.1, 5)]
y=np.array([f.subs(x, i) for i in a], dtype=float)
np.array([a, y]).T
array([[1.9    , 1.9    ],
       [1.92475, 1.92475],
       [1.9495 , 1.9495 ],
       [1.97425, 1.97425],
       [1.999  , 1.999  ],
       [2.001  , 2.001  ],
       [2.02575, 2.02575],
       [2.0505 , 2.0505 ],
       [2.07525, 2.07525],
       [2.1    , 2.1    ]])
limit(f,x, 2)
2

9) $\displaystyle \lim_{x \to a}x^n=a^n$

f=x**4
a=np.r_[np.linspace(1.9, 1.999, 5), np.linspace(2.001, 2.1, 5)]
y=np.array([f.subs(x, i) for i in a], dtype=float)
np.array([a, y]).T
array([[ 1.9       , 13.0321    ],
       [ 1.92475   , 13.7245247 ],
       [ 1.9495    , 14.4441822 ],
       [ 1.97425   , 15.19177735],
       [ 1.999     , 15.96802399],
       [ 2.001     , 16.03202401],
       [ 2.02575   , 16.84005053],
       [ 2.0505    , 17.6782428 ],
       [ 2.07525   , 18.54734243],
       [ 2.1       , 19.4481    ]])
limit(f,x, 2)
16

예 1)

$$\lim_{x \to -2}(3x^2+5x-9)= \lim_{x \to -2}3x^2+\lim_{x \to -2}5x+\lim_{x \to -2}-9$$
f=3*x**2+5*x-9
limit(f, x, -2)
-7
limit(3*x**2, x, -2)+limit(5*x, x, -2)+limit(-9, x, -2)
-7

예 2)

$$\lim_{x \to 2}\frac{t^2+4t-12}{t^2-2t}$$

위 함수는 x=0에서 분모가 0이 되므로 정의할 수 없습니다. 그러므로 0을 기준으로 별도의 영역에서 함수의 형태는 다음과 같습니다.

t=symbols("t")
f=(t**2+4*t-12)/(t**2-2*t)
f
$$\quad \color{blue}{\displaystyle \frac{t^{2} + 4 t - 12}{t^{2} - 2 t}}$$
x1=np.linspace(-3, -0.1, 100)
x2=np.linspace(0.1, 3, 100)
y1=np.array([f.subs(t, i) for i in x1], dtype="float")
y2=np.array([f.subs(t, i) for i in x2], dtype="float")
plt.figure(dpi=80)
plt.plot(x1, y1, label="t > 0")
plt.plot(x2, y2, label="t < 0")
plt.scatter(2, 4, color="green")
plt.xlabel("t", size=12, weight="bold")
plt.ylabel("f(t)", size=12, weight="bold")
plt.legend(loc='best')
plt.text(-3, 40, r"f(t)=$\mathbf{\frac{t^{2} + 4 t - 12}{t^{2} - 2 t}}$", size="13")
plt.show()

위 그림에서와 나타낸 것과 같이 t=2에 대한 f(t)값은 4입니다. 이 값은 f(t)를 인수분해에 의해 간단한 형태로 변환한 뒤 계산한 결과입니다.

f1=f.simplify()
f1
$\quad \color{blue}{\displaystyle \frac{t + 6}{t}}$
f1.subs(t, 2)
4

이 결과는 limit() 함수를 적용한 경우와 같습니다.

limit(f, x, 2)
4

예 3)

$$\lim_{x \to 0}\frac{2(-3+x)^2-18)}{x}$$
f=(2*(-3+x)**2-18)/x
limit(f, x, 0)
-12

댓글