[Python] Numerical method에 따른 Integration error 확인하기


[Python] Numerical method에 따른 Integration error 확인하기

TR(Trapezoidal Rule), SR(Simpson's Rule), TC(Trapezoidal with end Correction) 세가지 방법의 에러를 확인하는 파이썬 코드를 만들어보자. 주어진 함수는 f(x)=exp(x) 이고 적분구간은 [0, 4]이다. 9Points로 분할해보자. import numpy as np import matplotlib.pyplot as plt import scipy.integrate as spi #f(x)=exp(x) def f(x): return np.exp(x) def f_prime(x): return np.exp(x) # grid 선정 a = 0 b = 4 n = 8 h = (b - a) / n x = np.linspace(a, b, n+1) # 정적분 (numerical method와 에러 비교를 위해) result, error = spi.quad(f, a, b) # 각각의 Numerical method의 적분값 정의 def trape...


#correction #수치해석 #trapezoidal #TR #TC #SR #simpson #Python #integration #end #적분

원문링크 : [Python] Numerical method에 따른 Integration error 확인하기