複数関数受けれるオイラー法のコード
ここのコードが元
code: eular.py
import matplotlib.pyplot as plt
import math
import numpy as np
# 微分方程式の関数
def dxdt(x, t):
gradients = []
for i in range(len(x)):
gradients.append(1)
return gradients
# オイラー法
def euler(num, x0, t0, tn, h):
x = x0.copy()
t = t0.copy()
X = [[] for _ in range(num)]
T = [[] for _ in range(num)]
# 漸化式を計算
for t_count in range(n):
gradients = dxdt(x, t)
for i in range(num):
return X, T
num = 4
print(X)
print(T)
for i in range(len(T)):
plt.show()