很抱歉,这可能看起来是一个非常愚蠢的问题,但我需要问一下,在odeint中求解耦合微分方程时,是否可以只打印最终输出值?事实上,我正在尝试求解随机生成的时间间隔的两个耦合微分方程,并且只得到每个间隔的最终输出。
y[-1] 。例如:
y[-1]
import numpy as np import scipy.integrate as si def F(y, t): return [y[1], y[0]] t = np.arange(0, 1, 0.001) y = si.odeint(F, [1, 0], t) print(y[-1])
收益 [ 1.54190626 1.17365875] 该系统的精确解为y(t)=[cosh(t),sinh(t)];所示数字相当接近于cosh(1)和sinh(1)。
[ 1.54190626 1.17365875]