Skip to content
Advertisement

How to put initial condition of ODE at a specific time point using odeint in Python?

How to put initial condition of ODE at a specific time point using odeint in Python?

So I have y(0) = 5 as initial condition, following code works::

JavaScript

I wanna see the graph in both negative and positive time line.

So I change t = np.linspace(0,20) to t = np.linspace(-5,20), but then the initial condition is taken as y(-5) = 5.

How to solve this?

Advertisement

Answer

I do not think you can, according to the docs

But you can solve for positive and negative t‘s separately and then stich them together. Replace the relevant lines with

JavaScript

this produces sol

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement