기본 콘텐츠로 건너뛰기

pandas_ta를 적용한 통계적 인덱스 지표

삼각함수의 미분

내용

삼각함수(trigonometric functions)의 미분

sin, cos, tan의 미분

일반적으로 각을 표시하기 위해 그리스 문자 θ으로 사용합니다. 다음 함수를 고려해 봅니다.

y = sin(θ)

이 함수에서 조사할 것은 그 함수의 변화량 (미분 계수) $\frac{d(\sin(\theta))}{d\theta}$ 입니다. 즉, 각도 θ와 sin(θ)의 변화 사이의 관계를 찾는 것입니다. 특히 증가가 무한히 작을 경우가 주된 관심 사항입니다. 이러한 관계를 그림 1에 나타내었습니다.

import numpy as np
import pandas as pd
from sympy import *
import matplotlib.pyplot as plt
plt.figure(figsize=(5, 5))
a=plt.axes(xlim=(-1.5, 2.5), ylim=(-1.5, 2.5))
r=plt.Circle((0, 0), 1, facecolor="none", edgecolor="navy", linewidth=2, label="radius=r")
a.add_patch(r)
plt.arrow(0, 0, 0.8, np.sqrt(1-(-0.8)**2), color="green", label=r"$\mathbf{degree=\theta}}$")
plt.arrow(0, 0, 0.7, np.sqrt(1-(-0.7)**2), color="red", label=r"$\mathbf{degree=\theta+\Delta\theta}}$")
plt.hlines(0, -1.5, 1.5, color="black")
plt.vlines(0, -1.5, 1.5, color="black")
plt.vlines(0.7, 0,np.sqrt(1-(-0.7)**2), linestyle="--", color="red", label=r"$\mathbf{y+\Delta y}}$")
plt.vlines(0.8,0, np.sqrt(1-(-0.8)**2), linestyle="--", color="green", label=r"$\mathbf{y}}$")
plt.legend(loc="best", prop={"weight":"bold"})
plt.text(0.5, -0.2, "X", size=12, weight="bold")
plt.text(-0.2, 0.5,"Y", size=12, weight="bold")
plt.xticks([]) 
plt.yticks([])
plt.show()
그림 1. 원에서 각도의 변화.

그림 1은 반지름 r의 원에서 y는 높이, θ 각을 나타낼 수 있으며 r = 1인 경우 높이와 각 사이 y= sin(θ) 관계가 성립합니다. θ 변화에 따른 sin(θ) 즉, 높이의 변화를 dy(Δ y)라 할 수 있습니다. 새로운 높이는 y+dy가 되고 각은 θ+dθ 될 것입니다.

$$\begin{align} y+dy &= \sin(\theta+d\theta)\\ \rightarrow dy &= \sin(\theta+d\theta) - \sin(\theta) \end{align}$$

위 식의 우항은 삼각함수의 합법칙을 적용하여 식 1과 같이 전개할 수 있습니다.

$$\begin{align}\tag{1} &\sin(m)-\sin(n) = 2\cos\left(\frac{m+n}{2}\right)⋅\sin \left(\frac{m-n}{2}\right)\\ &\rightarrow  m = \theta+d\theta, n = \theta\\ &\begin{aligned}dy &= 2\cos\left(\frac{\theta+d\theta+\theta}{2}\right)⋅\sin\left(\frac{\theta+d\theta-\theta}{2}\right)\\ &= 2\cos \left(\theta+\frac{1}{2}d\theta \right)⋅\sin\left(\frac{1}{2}d\theta \right)\end{aligned} \end{align}$$

$\theta$ 무한히 작다면 다음 코드의 결과와 같이 그 값의 크기는 무시 가능하므로 위 식에서 $\theta+\frac{1}{2}d\theta \approx \theta$로 간주할 수 있으며 또한 각($\theta$)과 $\sin(\theta)$ 값이 거의 일치하기 때문에 $\sin \left(\frac{1}{2}\theta \right) \approx \frac{1}{2}\theta$이 성립합니다.

th=[0.001,0.0001, 0.00001, 0.000001]
rad=np.deg2rad(th)
np.around(rad, 8)
array([1.745e-05, 1.750e-06, 1.700e-07, 2.000e-08])
val=[N(sin(i), 8) for i in rad]
pd.DataFrame([rad, val], index=["radian", "sin(x)"])
0 1 2 3
radian 0.000017 0.000002 0.0 0.0
sin(x) 1.74e-5 1.74e-6 1.74e-7 1.74e-8

그러므로 위 식은 다음과 같이 정리 됩니다.

$$\begin{aligned} dy &= \frac{2\cos(\theta)}{2}d\theta\\ \frac{dy}{d\theta}&= \cos(\theta) \end{aligned}$$

위 함수 $y=\sin(\theta)$와 미분 함수인 $\cos(\theta)$는 각각 그림 2와 같습니다.

그림 2. sin(θ)와 미분 곡선.

식 1과 동일한 과정으로 y=cos(θ)와 y=tan(θ)의 미분을 유도하면 각각 식2와 3과 같습니다.

$$\begin{align}\tag{2} \cos(\theta)&= \sin \left(\frac{\pi}{2}-\theta \right)\\ y&=\cos(\theta)\\ dy&=d\left(\sin \left(\frac{\pi}{2}-\theta \right) \right)\\ &=\cos \left(\frac{\pi}{2}-\theta \right) \cdot d(-\theta)\\ &=-\cos\left(\frac{\pi}{2}-\theta \right) \cdot d(\theta)\\ \therefore \frac{dy}{d\theta}&=-\cos\left(\frac{\pi}{2}-\theta \right)\\ &=-\sin(\theta) \end{align}$$ $$\begin{align}\tag{3} y&=\tan(\theta)\\ &=\frac{\sin(\theta)}{\cos(\theta)}\\ \frac{dy}{d\theta}&=\frac{d(\sin(\theta))\cos(\theta)-\sin(\theta)d(\cos(\theta))}{\cos^2(\theta)}\\ &=\frac{\cos(\theta)\cos(\theta)+\sin(\theta)\sin(\theta)}{\cos^2(\theta)}\\ &=\frac{\cos^2(\theta)+\sin^2(\theta)}{\cos^2(\theta)}\\ &=\frac{1}{\cos^2(\theta)}\\ &=\sec^2(\theta) \end{align}$$

simpy 함수 diff()를 삼각함수의 미분에 적용할 수 있습니다.

theta=symbols("theta")
diff(sin(theta))
$\quad \small \color{navy}{\cos{\left(\theta \right)}}$
diff(cos(theta))
$\quad \small \color{navy}{ - \sin{\left(\theta \right)}}$
diff(tan(theta))
$\quad \small \color{navy}{ \tan^{2}{\left(\theta \right)} + 1}$

위 결과 tan2(θ)+1를 정리하면 다음과 같습니다.

$$\begin{align} \tan^2(\theta)+1&=\frac{\sin^2(\theta)}{\cos^2(\theta)}+1\\ &=\frac{1-\cos^2(\theta)}{\cos^2(\theta)}+1\\ &=\frac{1}{\cos^2(\theta)}\\ &=\sec^2(\theta) \end{align}$$
simplify(diff(tan(theta)))
$\quad \small \color{navy}{ \frac{1}{\cos^{2}{\left(\theta \right)}}}$

원의 총 각도는 2π 또는 360도 입니다. 어떤 총 기간을 T로 할 때 일정한 시간 t에 따라 각도의 변화는 다음과 같이 나타낼 수 있습니다.

$$\theta = 2\pi \frac{t}{T}$$

초당 주기(T)의 수를 주파수(frequency, n)라고 하면 $\quad \small \color{navy}{ n =\frac{1}{T}}$의 관계를 갖습니다. 이 관계를 위 식에 대입하면 다음과 같이 표현됩니다.

$$\theta =2 \pi nt$$

예)
  함수 $y = \sin(2 \pi nt)$를 미분 합니다.

이 식의 변수는 $\theta$가 아닌 시간 t에 대해 미분하기 위해 다음 관계를 적용합니다.

$$\begin{align} \frac{dy}{dt}&=\frac{dy}{d \theta}\frac{d \theta}{dt}\\ \rightarrow y&=\sin(\theta), \theta=2 \pi nt\\ \frac{dy}{dt}&=\cos(\theta)2n \pi\\ &=2n\pi \cos(2 \pi nt) \end{align}$$
n, t=symbols("n, t")
y=cos(2*pi*n*t)
y.diff(t)
$\quad \small \color{navy}{ - 2 \pi n \sin{\left(2 \pi n t \right)}}$

2차미분과 역함수 미분

삼각함수의 2차미분

sin과 cos의 미분은 각각 상호간의 함수가 전환됩니다. 이 관계를 사용하여 각 함수의 2차 미분을 계산할 수 있습니다.

$$\begin{align}\tag{4} \frac{d(\sin(\theta))}{d \theta}&=\cos(\theta)\\ \frac{d^2(\sin(\theta))}{d \theta^2}&=\frac{d(\cos(\theta))}{d \theta}\\ &=-\sin(\theta) \end{align}$$ $$\begin{align}\tag{5} \frac{d(\cos(\theta))}{d \theta}&=-\sin(\theta)\\ \frac{d^2(\cos(\theta))}{d \theta^2}&=-\frac{d(\sin(\theta))}{d \theta}\\ &=-\cos(\theta) \end{align}$$ $$\begin{align}\tag{6} \frac{d^2(\tan(\theta))}{d \theta}&=\frac{d\left(\frac{1}{\cos^2(\theta)} \right)}{d \theta}\\ &= \frac{2 \cos(\theta) \sin(\theta)}{\cos^4(\theta)}\\ &=\frac{2 \tan(\theta)}{\cos^2(\theta)}\\ &=2\tan(\theta)\sec^2(\theta)\\ \end{align}$$
theta=symbols("theta")
diff(sin(theta), theta, 2)
$\quad \small \color{navy}{- \sin{\left(\theta \right)}}$
diff(cos(theta), theta, 2)
$\quad \small \color{navy}{ - \cos{\left(\theta \right)}}$
simplify(diff(tan(theta), theta, 2))
$\quad \small \color{navy}{ \frac{2 \tan{\left(\theta \right)}}{\cos^{2}{\left(\theta \right)}}}$

sin(x), cos(x)함수의 2차 미분계수는 원함수와 부호만 반대인 결과를 갖습니다.

표 1. sin, cos, tan 함수의 미분규칙
함수(y)1차 미분$\left(\frac{dy}{d\theta}\right)$2차 미분$\left(\frac{d^2y}{d\theta^2}\right)$
sin(θ) cos(θ) -sin(θ)
cos(θ) -sin(θ) -cos(θ)
tan(θ) sec2(θ) 2tan(θ)sec2(θ)

역함수의 미분

식 7은 sin, cos, tan의 역함수를 나타낸 것입니다.

$$\begin{align}\tag{7} & \;y=\arcsin(x) \;\Leftrightarrow \; y = \sin^{-1}(x)\;\Leftrightarrow \; x=\sin(y)\\ & \;y=\arccos(x)\;\Leftrightarrow \; y = \cos^{-1}(x)\;\Leftrightarrow \; x=\cos(y)\\ & \;y=\arctan(x) \;\Leftrightarrow \; y = \tan^{-1}(x)\;\Leftrightarrow \; x=\tan(y)\\ \end{align}$$

예를 들어 $y = \sin^{-1}(x)$는 x = sin(y)를 의미합니다. 이 삼각함수의 역함수의 미분은 다음과 같습니다.

$$\begin{align} y=\sin^{-1}(x)& \Leftrightarrow x=\sin(y)\\ \frac{dx}{dy}&=\cos(y)\\ \frac{dy}{dx}&=\frac{1}{\cos(y)} \end{align}$$

삼각함수의 합공식 sin2(y) + cos2(y) = 1을 적용하여 위 결과를 정리할 수 있습니다.

$$\begin{align} \cos(y)&=\sqrt{1-\sin^2(y)}\\ &=\sqrt{1-x^2}\\ \frac{dy}{dx}&=\frac{1}{\cos(y)}\\ &=\frac{1}{\sqrt{1-x^2}} \end{align}$$
x, y=symbols("x, y")
eq=y-asin(x) #원 식 
eq_x=solve(eq, x) #원 식을 x에 대해 정리(역함수) 
eq_x
[sin(y)]
eq_y=solve(eq, y) #원 식을 y에 대해 정리
eq_y
[asin(x)]
dxdy=eq_x[0].diff(y) # 역함수 미분 
dxdy
$\quad \small \color{navy}{ \cos{\left(y \right)}}$
(1/dxdy).subs(y, eq_y[0])
$\quad \small \color{navy}{ \frac{1}{\sqrt{1 - x^{2}}}}$
eq_y[0].diff(x)#원 함수 미분
$\quad \small \color{navy}{ \frac{1}{\sqrt{1 - x^{2}}}}$

예)
  cos-1(x)의 미분합니다.

이 함수 역시 위의 sin-1(x)와 동일한 방식으로 계산할 수 있습니다.

$$\begin{align} y = \cos^{-1}(x)& \rightarrow x = \cos(y)\\ \frac{dx}{dy} &= - \sin(y)\\ &= - \sqrt{1-\cos^2(y)}\\ \frac{dy}{dx} &= -\frac{1}{\sin(y)}\\ &= -\frac{1}{\sqrt{1-\cos^2(y)}}\\ &= -\frac{1}{\sqrt{1-x^2}} \end{align}$$
x, y=symbols("x, y") 
eq=y-acos(x) 
eq_x=solve(eq, x) 
eq_x
[cos(y)]
eq_y=solve(eq, y) #원 식을 y에 대해 정리 
eq_y
[acos(x)]
dxdy=eq_x[0].diff(y) # 역함수 미분  
dxdy
$\quad \small \color{navy}{ - \sin{\left(y \right)}}$
(1/dxdy).subs(y, eq_y[0])
$\quad \small \color{navy}{ - \frac{1}{\sqrt{1 - x^{2}}}}$
eq_y[0].diff(x)#원 함수 미분
$\quad \small \color{navy}{ - \frac{1}{\sqrt{1 - x^{2}}}}$

예)
  tan-1(x)의 미분합니다.

$$\begin{align} y = \tan^{-1}(x)& \rightarrow x = \tan(y) = \frac{\sin(y)}{\cos(y)}\\ \frac{dx}{dy}& =\frac{1}{\cos^2(y)}\\ & =\frac{\sin^2(y)+\cos^2(y)}{\cos^2(y)}\\ & = 1 + \tan^2(y)\\ & = 1 + x^2\\ \frac{dy}{dx}& =\frac{1}{1+x^2} \end{align}$$
x= symbols("x")
diff(atan(x))
$\quad \small \color{navy}{ \frac{1}{x^{2} + 1}}$
표 2. 역삼각함수의 미분규칙
함수(y)1차 미분$\left(\frac{dy}{dx}\right)$
sin-1(x) $\frac{1}{\sqrt{1-x^2}}$
cos-1(x)$-\frac{1}{\sqrt{1-x^2}}$
tan-1(x)$\frac{1}{1+x^2}$

예)
  y = cos3(θ)을 미분해 봅니다.

이 식에서 cos3(θ) = (cos(θ))3이 성립하므로 cos(θ) = u로 치환하여 미분할 수 있습니다.

theta, u=symbols("theta u")
u1=cos(theta)
y=u**3
dydu=y.diff(u)
dydu
$\quad \small \color{navy}{ 3 u^{2}}$
dudth=u1.diff(theta)
dudth
$\quad \small \color{navy}{ - \sin{\left(\theta \right)}}$
dydth=dydu*dudth
dydth
$\quad \small \color{navy}{ - 3 u^{2} \sin{\left(\theta \right)}}$
dydth.subs(u, u1)
$\quad \small \color{navy}{ - 3 \sin{\left(\theta \right)} \cos^{2}{\left(\theta \right)}}$
diff(cos(theta)**3, theta) #원 함수를 직접미분
$\quad \small \color{navy}{ - 3 \sin{\left(\theta \right)} \cos^{2}{\left(\theta \right)}}$

예)
 y = sin(x+a)를 미분합니다.

이 함수 역시 치환 방법을 적용합니다. 이 문제에 대한 미분 과정은 다음과 같습니다.

$$\begin{aligned} &u=x+a \rightarrow y=\sin(u)\\ &\frac{du}{dx}=1\\ &\frac{dy}{du}=\cos(u)\\ &\frac{dy}{du}\frac{du}{dx}=\cos(u)\frac{du}{dx}\\ &\therefore \frac{dy}{dx}=\cos(x+a) \end{aligned}$$
a, x=symbols("a x")
y=sin(x+a)
y.diff(x)
$\quad \small \color{navy}{ \cos{\left(a + x \right)}}$

결과적으로 치환한 부분의 미분과 전체 미분을 곱한 것과 같습니다.

예)
  y = log(sin(θ))를 미분합니다. sin(θ) = u로 치환하면 y = log(u)이 됩니다.

theta, u=symbols("theta u")
y=log(sin(theta))#원 함수 
y.diff(theta)
$\quad \small \color{navy}{ \frac{\cos{\left(\theta \right)}}{\sin{\left(\theta \right)}}}$
u1=sin(theta) #원함수의 부분을 u(=u1)로 치환 
y1=log(u)
dydu=y1.diff(u)
dydu
$\quad \small \color{navy}{ \frac{1}{u}}$
dudth=u1.diff(theta)
dudth
$\quad \small \color{navy}{ \cos{\left(\theta \right)}}$
dydth=dydu*dudth
dydth
$\quad \small \color{navy}{ \frac{\cos{\left(\theta \right)}}{u}}$
dydth.subs(u, u1)
$\quad \small \color{navy}{ \frac{\cos{\left(\theta \right)}}{\sin{\left(\theta \right)}}}$

예)
 y = cot(θ)를 미분합니다.

$$\begin{align} y &= \cot(\theta) \\    &= \frac{\cos(\theta)}{\sin(\theta)}\\ \frac{dy}{dx} &=\frac{-\sin^2(\theta)-\cos^2(\theta)}{\sin^2(\theta)}\\ &= \frac{-1}{\sin^2(\theta)}\\ &= -\operatorname{csc}^2(\theta) \end{align}$$
theta=symbols("theta")
y=cot(theta)
dy=diff(y, theta)
simplify(dy)
$\quad \small \color{navy}{ - \frac{1}{\sin^{2}{\left(\theta \right)}}}$

예)
 y=tan(3θ)를 미분합니다.

theta=symbols("theta")
y=tan(3*theta)
dy=diff(y, theta)
simplify(dy)
$\quad \small \color{navy}{ \frac{3}{\cos^{2}{\left(3 \theta \right)}}}$

예)
 $y = \sqrt{1 + 3\tan^2(\theta)}$를 미분합니다.

이 함수에서 $3\tan^2(\theta) = u$로 치환할 수 있습니다.

theta, u=symbols("theta u")
y=sqrt(1+3*tan(theta)**2)
y.diff(theta)
$\quad \small \color{navy}{ \frac{3 \left(2 \tan^{2}{\left(\theta \right)} + 2\right) \tan{\left(\theta \right)}}{2 \sqrt{3 \tan^{2}{\left(\theta \right)} + 1}}}$
u1=3*tan(theta)**2
y1=sqrt(1+u)
dydu=y1.diff(u)
dydu
$\quad \small \color{navy}{ \frac{1}{2 \sqrt{u + 1}}}$
dudth=u1.diff(theta)
dudth
$\quad \small \color{navy}{ 3 \left(2 \tan^{2}{\left(\theta \right)} + 2\right) \tan{\left(\theta \right)}}$
dydth=dydu*dudth
dydth
$\quad \small \color{navy}{ \frac{3 \left(2 \tan^{2}{\left(\theta \right)} + 2\right) \tan{\left(\theta \right)}}{2 \sqrt{u + 1}}}$
dydth.subs(u, u1)
$\quad \small \color{navy}{ \frac{3 \left(2 \tan^{2}{\left(\theta \right)} + 2\right) \tan{\left(\theta \right)}}{2 \sqrt{3 \tan^{2}{\left(\theta \right)} + 1}}}$

예)
 y = sin(x)cos(x)를 미분합니다.

이 함수의 미분은 곱법칙을 적용합니다.

$$\begin{align} y = A(x)B(x) & \rightarrow \frac{dy}{dx}=A'(x)B(x)+A(x)B'(x)\\ \frac{dy}{dx} & = d(\sin(x)) \cos(x)+\sin(x)d(\cos(x))\\ &= \cos^2(x)-\sin^2(x) \end{align}$$
x=symbols("x")
y=sin(x)*cos(x)
dy=diff(y, x)
dy
$\quad \small \color{navy}{ - \sin^{2}{\left(x \right)} + \cos^{2}{\left(x \right)}}$

댓글

이 블로그의 인기 게시물

[Linear Algebra] 유사변환(Similarity transformation)

유사변환(Similarity transformation) n×n 차원의 정방 행렬 A, B 그리고 가역 행렬 P 사이에 식 1의 관계가 성립하면 행렬 A와 B는 유사행렬(similarity matrix)이 되며 행렬 A를 가역행렬 P와 B로 분해하는 것을 유사 변환(similarity transformation) 이라고 합니다. $$\tag{1} A = PBP^{-1} \Leftrightarrow P^{-1}AP = B $$ 식 2는 식 1의 양변에 B의 고유값을 고려한 것입니다. \begin{align}\tag{식 2} B - \lambda I &= P^{-1}AP – \lambda P^{-1}P\\ &= P^{-1}(AP – \lambda P)\\ &= P^{-1}(A - \lambda I)P \end{align} 식 2의 행렬식은 식 3과 같이 정리됩니다. \begin{align} &\begin{aligned}\textsf{det}(B - \lambda I ) & = \textsf{det}(P^{-1}(AP – \lambda P))\\ &= \textsf{det}(P^{-1}) \textsf{det}((A – \lambda I)) \textsf{det}(P)\\ &= \textsf{det}(P^{-1}) \textsf{det}(P) \textsf{det}((A – \lambda I))\\ &= \textsf{det}(A – \lambda I)\end{aligned}\\ &\begin{aligned}\because \; \textsf{det}(P^{-1}) \textsf{det}(P) &= \textsf{det}(P^{-1}P)\\ &= \textsf{det}(I)\end{aligned}\end{align} 유사행렬의 특성 유사행렬인 두 정방행렬 A와 B는 'A ~ B' 와 같...

유리함수 그래프와 점근선 그리기

내용 유리함수(Rational Function) 점근선(asymptote) 유리함수 그래프와 점근선 그리기 유리함수(Rational Function) 유리함수는 분수형태의 함수를 의미합니다. 예를들어 다음 함수는 분수형태의 유리함수입니다. $$f(x)=\frac{x^{2} - 1}{x^{2} + x - 6}$$ 분수의 경우 분모가 0인 경우 정의할 수 없습니다. 이와 마찬가지로 유리함수 f(x)의 정의역은 분모가 0이 아닌 부분이어야 합니다. 그러므로 위함수의 정의역은 분모가 0인 부분을 제외한 부분들로 구성됩니다. sympt=solve(denom(f), a); asympt [-3, 2] $$-\infty \lt x \lt -3, \quad -3 \lt x \lt 2, \quad 2 \lt x \lt \infty$$ 이 정의역을 고려해 그래프를 작성을 위한 사용자 정의함수는 다음과 같습니다. def validX(x, f, symbol): ① a=[] b=[] for i in x: try: b.append(float(f.subs(symbol, i))) a.append(i) except: pass return(a, b) #x는 임의로 지정한 정의역으로 불연속선점을 기준으로 구분된 몇개의 구간으로 전달할 수 있습니다. #그러므로 인수 x는 2차원이어야 합니다. def RationalPlot(x, f, sym, dp=100): fig, ax=plt.subplots(dpi=dp) # ② for k in x: #③ x4, y4=validX(k, f, sym) ax.plot(x4, y4) ax.spines['left'].set_position(('data', 0)) ax.spines['right...

turtle로 정오각형 그리기

정오각형 그리기  오각형을 그리는 것 역시 정사각형 , 정삼각형 을 그리는 것과 유사한 과정을 거칩니다. 단지 각 꼭지점의 각도만이 다르지요. 그러면 정오각형의 각 모서리의 각도는 어떻게 될까요? 이를 생각하기에 앞서 각 도형의 내각을 먼저 생각해보죠. 우리는 삼각형의 내각의 합을 알고 있습니다. 이를 이용하면 각 도형에서 삼각형이 몇개가 존재하는지를 알아보고 "삼각형의 갯수×180"로 그 도형의 내각의 합을 구할 수 있을 것입니다. 다음 그림을 볼까요? 위 그림의 사각형은 1개의 대각선으로 2개의 삼각형으로 구성됩니다. 오각형의 경우 2개의 대각선으로 3개의 삼각형으로 구성됩니다. 즉, 다음의 관계를 보이지요. 사각형의 내각 : 삼각형 2개 2×180=360 한각의 값  360/4=90 오각형의 내각 : 삼각형 3개 3×180=540 한각의 값  540/5=108 육각형의 내각 : 삼각형 4개 4×180=720 한각의 값  720/6=120 ... 위 그림에서 내각과 외각의 관계를 보면 위 그림의 검은색은 각 모서리의 내각이고 빨간색은 외각을 나타냅니다. 외각은 내각을 이루는 하나의 선을 연장했을 경우 상대되는 각도이라고 했습니다. 그러므로 오각형의 경우 내각 108도에 대한 외각은 72도입니다. 특이할 사항은 사각형이나 오각형이나 외각의 합은 360입니다. 즉, 모든 도형의 외각의 합은 360도입니다. (삼각형의 외각의 합을 구해보세요.) 그러므로 모든 정다각형에서 하나의 외각은 다음과 같이 계산될 수 있겠지요. 360/변수의 수=다각형에서 하나의 외각 위에서 회전을 할 경우 내각이 아닌 외각을 사용해야 함을 알았습니다. 그러므로 오각형을 그리는 계획은 다음과 같이 작성할 수 있겠죠. 1) 지정한 길이만큼 앞으로 이동합니다. 2) 오른쪽 또는 왼쪽으로 72도를 회전합니다. 3) 앞으로 동일한 길이만큼 이동합니다. 4) 오른쪽 또는 왼쪽으로 72도 만큼 이동합니다. 5)1번부터 4번 ...