-
Euler's Method, 오일러 방법, 오일러 적분Mathematics 2020. 9. 10. 23:56
Overview
미분방정식 $\frac{dy}{dx}=f(x, y)$의 수치해를 구하는 방법
작은 상수 $h$를 고정
$x_{k+1}=x_k+h$라 두자
초기값 $(x_0, y_0)$가 주어져 있을 때, 다음의 식을 이용하여 수치해를 구함.
$\therefore y_{k+1}=y_k+hf(x_k, y_k)$
Example
import numpy as np import matplotlib.pyplot as plt # expression y = lambda x: 2**x y_diff = lambda x: (2**x)*np.log(2) # derivative of exp # settings h = 0.1 x_range = np.arange(0, 3, 0.1) # initial value init_x = x_range[0] init_y = y(init_x) # run y_euler = [init_y] for x in x_range[1:]: y_k1 = y_euler[-1] + h*y_diff(x) y_euler.append(y_k1) # plot plt.plot(x_range, y(x_range), label="Actual") plt.plot(x_range, y_euler, label='Euler Method');
output error gets larger as $x$ increases 'Mathematics' 카테고리의 다른 글
Optimization Course [최민주 교수님 최적화 수업] (0) 2020.09.11 Butterworth Filter explained with codes (0) 2020.09.10 Notion of partial derivative (0) 2020.09.10