[Python] 2nd ODE with numerical method(2)


[Python] 2nd ODE with numerical method(2)

이전의 내용에 Implicit Euler method를 추가해보자. Implicit Euler method는 비선형 방정식을 풀어야 하는데 아래의 ODE에 대해서 풀이된 비선형 방정식의 형태는 다음과 같다. 따라서 코드는 아래와 같다. import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt # 주어진 미분 방정식 # y[1]=y', y[0]=y # dydt = [y', y''], y''=-omega**2 * y def model(y, t): dydt = [y[1], -omega**2 * y[0]] return dydt # Explicit Euler method 정의 def explicit_euler(y0, v0, omega, dt, num_steps): y = np.zeros(num_steps + 1) v = np.zeros(num_steps + 1) y[0] = y0 v[0] = v0...


#2nd #euler #implicit #method #numerical #ode #python #수치해석

원문링크 : [Python] 2nd ODE with numerical method(2)