Intuition Concept

์ด๊ฒŒ ์ •์ ๋ถ„์ด์ฃ ! ํ•˜์ง€๋งŒ ์ปดํ“จํ„ฐ๋Š” ์—ฐ์†์ ์ธ ๊ฐ’์„ ์ธ์‹ํ•  ์ˆ˜ ์—†๊ธฐ ๋•Œ๋ฌธ์—ย 

(์‚ฌ์‹ค ์ ๋“ค์˜ ์ง‘ํ•ฉ์ด ์„ ์ด๊ธด ํ•˜์ฃ ) ์ด์‚ฐ์ ์ธ ๊ฐ’์— ๋Œ€ํ•ด์„œ ์ด ๊ฐ’์— ๊ทผ์‚ฌํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

๊ทธ ์ „์— ์ด ์ •์ ๋ถ„์˜ ์ •์˜๋ฅผ ์–ด๋–ค ๊ฒƒ์—์„œ ํ™•์žฅํ–ˆ์—ˆ์ฃ ?

๋ฐ”๋กœ ๊ตฌ๋ถ„๊ตฌ์ ๋ฒ•์œผ๋กœ ๋‚˜ํƒ€๋ƒˆ์—ˆ์Šต๋‹ˆ๋‹ค.ย 

๊ณ ๋“ฑํ•™๊ต ๊ณผ์ •์—์„œ๋Š” ์ง์‚ฌ๊ฐํ˜•์˜ ํ•ฉ์˜ ํ˜•ํƒœ๋กœ ๋‚˜ํƒ€๋‚ด์—ˆ์ง€๋งŒ ์šฐ๋ฆฌ๋Š” ๋ฌดํ•œ๊ฐœ์˜ ์‚ฌ๊ฐํ˜•์˜ ํ•ฉ์œผ๋กœย ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์—†๊ณ  ์ด์‚ฐ์  ๊ทผ์‚ฌํ•˜๋Š” ๋ฐฉ๋ฒ•์„ Trapezoidal rule ์ด๋ผ ํ•ฉ๋‹ˆ๋‹ค.

1์ฐจ์‹์ธ Trapezoidal rule์ด ๊ฐ€์žฅ ์‰ฌ์šฐ๋ฏ€๋กœ ์ด๋•Œ์˜ ๊ทผ์‚ฌ์‹์„ ์œ ๋„ํ•ด๋ณด๋ฉด,

f1์„ ์œ„์˜ ์‹์— ๋Œ€์ž…ํ•˜๋ฉด,

n๊ฐœ์˜ ์‚ฌ๋‹ค๋ฆฌ๊ผด์„ ๋ชจ๋‘ ๋”ํ•˜๊ฒŒ ๋˜๋ฉด,

๊ทธ๋Ÿฐ๋ฐ ๋‘ ์ ์„ ๊ตณ์ด ์ง์„ ์œผ๋กœ ์ด์„ ํ•„์š”๋Š” ์—†๊ฒ ์ฃ .ย 

ํ•ด๋‹น ๋ถ€๋ถ„์„ ๋Œ€๋ณ€ํ•  ์ˆ˜ ์žˆ๋Š” ๋‹ค๋ฅธ ๊ณก์„ ์„ ์ฑ„ํƒํ•ด์„œ ๊ทธ ์‹์— ๋Œ€ํ•ด ์ ๋ถ„์„ ํ•ด๋„ ๊ดœ์ฐฎ์„ ๊ฒ๋‹ˆ๋‹ค.

๊ฒฐ๊ตญ ์ด ๋ฐฉ๋ฒ•๋“ค์€ ์ˆ˜์น˜ํ•ด์„์—์„œ ๋‰ดํ„ด-์ฝ”์ธ  ๋ฒ•์น™๋“ค์˜ ๊ฒฝ์šฐ๋“ค ์ž…๋‹ˆ๋‹ค.

n์ฐจ ๋‹คํ•ญ์‹์˜ ๊ฒฝ์šฐ๋ฅผ ์ƒ๊ฐํ•˜๋ฉด ์ด๋Ÿฐ์‹์œผ๋กœ ๋ฉ๋‹ˆ๋‹ค.

๋‘ ์ ์„ ์ž‡๋Š”๋‹ค๋Š” ๊ด€์ ์—์„œ ์ด๊ฑด ๋ณด๊ฐ„๋ฒ•์—์„œ ํ•œ ๊ฒƒ๊ณผ ์‚ฌ์‹ค ๋น„์Šทํ•ด์š”.ย 

์–ด๋–ค ์ฐจ์ˆ˜์˜ ๋‹คํ•ญ์‹์„ ์‚ฌ์šฉํ•˜๋Š๋ƒ์— ๋”ฐ๋ผ, quad, quadgk, quadl, triplequad, integral, integral2, โ€ฆ

์ด๋ ‡๊ฒŒ ๋งŽ์€ ๋ฐฉ๋ฒ•์ด ์กด์žฌํ•ฉ๋‹ˆ๋‹ค. ์ด ์ค‘ ํ•œ๊ฐ€์ง€๋งŒ ์‚ดํŽด๋ณด๋ฉด, quadํ•จ์ˆ˜๋Š” Simpsonโ€™s rule์„ ๋”ฐ๋ฆ…๋‹ˆ๋‹ค.

P(x)๋ผ๋Š” 2์ฐจ๋ฐฉ์ •์‹์œผ๋กœ f(x)์˜ ๊ทผ์‚ฌ๊ฐ’์„ ๊ตฌํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.
์ž์„ธํ•œ ๋‚ด์šฉ์€ ํ•˜๋‹จ ๋งํฌ๋ฅผ ๋”ฐ๋ผ์„œ ๊ณต๋ถ€ํ•ด๋ณด๊ธธ ๋ฐ”๋ž๋‹ˆ๋‹ค.

Function

Trapezoidal rule ์ ๋ถ„๊ทผ์‚ฟ๊ฐ’ = trapz(x_array, y_array)

์ž…๋ ฅ๋ณ€์ˆ˜๋Š” array์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.ย  ๋งคํŠธ๋žฉ์—์„œ ํ•จ์ˆ˜๋ž€ ๊ฒฐ๊ตญ ๋‘ array๊ฐ„์˜ ๊ด€๊ณ„๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.ย 

x, y array ์˜ ๊ธธ์ด๋Š” ๊ฐ™์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ Simpsonโ€™s rule ์„ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์€,

Simpson's rule ์ ๋ถ„๊ทผ์‚ฟ๊ฐ’ = quad(function, ์‹œ์ž‘๊ฐ’, ๋๊ฐ’)

ํ•จ์ˆ˜๋ฅผ ๋”ฐ๋กœ ์ •ํ•ด์ค„ ํ•„์š” ์—†์ด ์ž…๋ ฅ๋ณ€์ˆ˜๋กœ ๋ฐ›๋Š”๋‹ค๋Š” ์ ์—์„œ ์ฐจ์ด๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

Example

0 < x < 1 ์˜ ๋ฒ”์œ„๋‚ด์—์„œ x^2์˜ ์ ๋ถ„๊ฐ’์„ ๊ตฌํ•ด๋ผ.

Trapezoidal rule ๋ฅผ ๋งŒ์กฑํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ค์–ด๋ณด์ž.

function [I]=trapm(a,b,n,f) 
h=(b-a)/n; 
xp=linspace(a,b,n); 
yp=f(xp); 
sumf=0 for i=2:n     
	sumf=sumf+yp(i)+yp(i-1); 
end 
I=(h/2)*sumf;

Trapezoidal rule ์˜ ์ตœ์ข… ์‹์„ ๊ทธ๋Œ€๋กœ ์˜ฎ๊ฒผ๋‹ค.

์ ๋ถ„๊ฐ’์„ ๊ตฌํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์ด ํ•จ์ˆ˜๋ฅผ ๊ฐ€์ ธ๋‹ค ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.

f = @(x) x.^2; tramp_int_x = Trapm(0,1,100,f) 
trapm_int_x =      0.3333

trapz ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ด๋ณด๋ฉด,

f = @(x) x.^2; 
xp = linspace(0,1,100); 
yp = f(xp); 
trapz_int_x = trapz(xp, yp)
trapz_int_x =      
	0.3334

Simpsonโ€™s rule ๋„ ์‚ฌ์šฉํ•ด๋ณด์ž.

f = @(x) x.^2; 
simp_int_x = quad(f, 0, 1)
simp_int_x =     
	0.3333

Simpsonโ€™s rule ๋กœ๋„ ๊ฐ™์€ ๊ฐ’์„ ์–ป์„ ์ˆ˜ ์žˆ๋‹ค.

Reference