I explain the question and reach the problem at the end of explanation.
In order to solve function f
as an ODE with python,
at first we must set an initial point or initial condition (x0=0.2
). Then, according to codes which I have searched on internet and sources, we should choose a range (time point) for solving that and plotting. For example t=np.linspace(0,5,20)
which divides the range between 0
to 5
into 20
sections and we have 20 outputs.
Sol=odeint(f,x0,t)
...
The problem is, I would like to have just one output at one time point, I set an initial point for example x0=0.2
, now I want to have one answer at the specific point which I choose, for example at the point of 3.4
.
When we plot the ODE we have all answers from first point to final point, but I want to have optional choice to set an specific points instead of using linspace(min, max,n)
The t
argument can contain just two points, with the first element being the time value of x0
(the initial condition), and the second being the final time that you are interested in.
t0 = 0
t1 = 123.45 # final time that you are interested in
sol = odeint(f, x0, [t0, t1])
Then the values at time t1
are x1 = sol[-1]
.
If the time span between t0
and t1
is long enough, the solver might make the maximum allowed number of internal steps before reaching t1
. That limit can be changed with the mxstep
argument.