I am sorry this may appear as a pretty dumb question, but I need to ask whether it is possible to print only the final output value while solving coupled differential equations in odeint? Actually I am trying to solve two coupled differential equations for time intervals generated randomly and get only the final output printed for each interval.
The last element of the array of y-values is y[-1]
. For example:
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])
returns [ 1.54190626 1.17365875]
. The exact solution of this system is y(t) = [cosh(t), sinh(t)]; the numbers shown are reasonably close to cosh(1) and sinh(1).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.