Solve Differential Equations in Python

preview_player
Показать описание

y = odeint(model, y0, t)

model: Function name that returns derivative values at requested y and t values as dydt = model(y,t)
y0: Initial conditions of the differential states
t: Time points at which the solution should be reported. Additional internal points are often calculated to maintain accuracy of the solution but are not reported.
Рекомендации по теме
Комментарии
Автор

My homework is done in 5 mins. Thank you!

frozenburrito
Автор

Let me tell you something, I was looking for your videos panicking for time, but here you are explaining every little detail. That's what make a great tutorial. Thanks Prof.

trevorsimpson
Автор

You have saved my research projects, thank you

emmanuelmasemola
Автор

Thank you so much for these lucid, thorough tutorials. Very helpful

AJ-etvf
Автор

These videos are awesome. I modified your code to meet my needs and it helped a lot. I wish YouTube had a rating system. I would rate contents on your channel 10 out 10. Again, thank you.

ssrwarrior
Автор

Thanks a lot. I used to solve these functions with matlab
It's really interesting to try Python.
Easy to understand~

ronaldoadrian
Автор

Another way to implement the step is to define a u(t) with arbitrary parameters and define these parameters in the args in odeint. Ploting the u(t) can be done by using the np.vectorize function

mpja
Автор

What’s the point of the variable tspan @21:45. It was defined but never used. Was it supposed to replace t in odeint?

tylerriley
Автор

Hi, Thanks for the video and codes. In problem 4, when you want to get a step response, the input value of a given time is fixed and fed to model function. But odeint changes the step size and moves in time (back and forth, if you print(t) in model function) . For example, while it works on time span of [2.7, 2.8], it jumps also to t=6.3. During this process u[i] is fixed and it is zero even for t=6.3. Won't is possibly cause erroranous results? I'm not an expert in this area and details of how the solver works but this observation made me confused.

afsanehgharouni
Автор

Very helpful, much better than the Simple/Complex video by you guys

GreenCrap
Автор

Professor how would I solve this system of first order edos numerically by plotting the graph for the different values ​​of (n). the derivatives are in relation to ha (r).






a'/r = -e^2*v^2*(g^2 - 1)



g' = - a*g/r





given the boundary conditions

a(0) = n a(inf)=0
g(0) = 0 g(inf)=1





where (e)=0.5 and (v)=1 are constant. please give a helping hand there, I looked for and did not find any problems like this on the matlab website.



I'm from Brazil.

edholanda
Автор

Thank you very much! clear and concise!

yem.t.
Автор

Hello Professor, I would like to thank you for the excellent content. I have one question regarding problem 4. Could we solve it as problem 3 ? I mean avoiding the 'for' loop and also insterting the 'u(t)' in an 'if' statement inside the function 'model'

kristianmr
Автор

Awesome. How could I solve d^2y/dx^2=y(x)/1+y(x) with boundary conditions y'(0)=0 and y(a)=1 in which a is a parameter?

homazeinali
Автор

PROBLEM 4
def functionModel5(z2, t):
if t < 5:
u = 0
else:
u = 1
x = z2[0]
y = z2[1]
dxdt = (-x + u)/2
dydt = (-y + x)/5
return dxdt, dydt
z2_0 = [0, 0]
t = np.linspace(0, 14)
z2 = odeint(functionModel5, z2_0, t)
x = z2[:, 0]
y = z2[:, 1]
plt.plot(t, x, 'b-')
plt.plot(t, y, 'r:', linewidth = 2)
plt.title("Step-function / double Function Solution", fontsize = 14)
plt.xlabel('Time-Axis', fontsize = 13)
plt.ylabel('Y-Axis', fontsize = 13)
plt.legend(['x(t)', 'y(t)'], loc = 'best')

kqnrqdtqqtttel
Автор

Thank you Professor. Could you please give an example in solving system of linear differential equations where the parameter are also function of time. For example at time 28:30 of this video, kr1, kr2 .... are constant parameter. How do we solve if these are also function of time?

devrajsadaula
Автор

For the last problem: Why didn't you use if/else for u function, as you've already done in the Problem 2? Thanks!

aksa
Автор

Are there units on time? can you specify weather it's minutes, hours, etc.?

lillianmulligan
Автор

Cool video, thanks.
Do you know how to force the odeint to deal with stiff problems?
It seems that the automatic recognition of the problem's stiffness of the lsoda fortran code is not always working right.

MrAppleman
Автор

Thanks for the nice lecture on python for differential equation.
How to plot impulsive differential equations?

RakeshKumar-wxhm