numerical differential equation

Thread Starter

karas

Joined Sep 8, 2011
216
my function is dy/dt=k*y*exp(450/y) k is constant and y(0)=40 and y(15)=95 solve this equation by using ode45 can someone pleaseeeeeeeeeee check the code and make it work .

tspan = [0 300];
y0 = 40;y15=95;
[t,y] = ode45(@(t,y) 'k'*y*exp(450/y), tspan, y0,y15);
plot(t,y,'-o')
 

WBahn

Joined Mar 31, 2012
32,829
I'm not familiar with "ode45".

What tool are you using? Mathematica? Matlab? Bob's ODE Solver?

You might get more responses if you provide more information.

What is your tspan for? I'm assuming it's the time span you are running the integration over, but then how does your call to ode45() know at what value of t the function is supposed to be equal to y15? It seems like it would be trying to match it at t=300, wouldn't it?

Have you tried finding k through other means, at least to backstop whatever results you eventually get with this approach?

Using Excel, in about three minutes I got a value for k that is just a few percent over 1E-4 (using the simplest form of integration you can imagine, which could be throwing my result off). How does that compare with what you got?
 
Last edited:

MrAl

Joined Jun 17, 2014
13,704
Hi,

That's probably referring to the Runge-Kutta-Fehlberg Method commonly referred to as RKF45.
It's a combination of fourth and fifth order numerical methods for solving ODE's.
Here though he seems ot be referring to some programmed language already made for that, i can only guess what package he is using. Usually the asker states that such as MatLab or something (i would guess that's it).
 
Last edited:

Thread Starter

karas

Joined Sep 8, 2011
216
I'm not familiar with "ode45".

What tool are you using? Mathematica? Matlab? Bob's ODE Solver?

You might get more responses if you provide more information.

What is your tspan for? I'm assuming it's the time span you are running the integration over, but then how does your call to ode45() know at what value of t the function is supposed to be equal to y15? It seems like it would be trying to match it at t=300, wouldn't it?

Have you tried finding k through other means, at least to backstop whatever results you eventually get with this approach?

Using Excel, in about three minutes I got a value for k that is just a few percent over 1E-4 (using the simplest form of integration you can imagine, which could be throwing my result off). How does that compare with what you got?
Hi tspan is my time range , y15 is the value of y at t=15
 

Thread Starter

karas

Joined Sep 8, 2011
216
Hi,

That's probably referring to the Runge-Kutta-Fehlberg Method commonly referred to as RKF45.
It's a combination of fourth and fifth order numerical methods for solving ODE's.
Here though he seems ot be referring to some programmed language already made for that, i can only guess what package he is using. Usually the asker states that such as MatLab or something (i would guess that's it).
Yes it is RKF45 i am using MATLAB
 

MrAl

Joined Jun 17, 2014
13,704
Yes it is RKF45 i am using MATLAB
Hello again,

Ok i can only guess here then because i dont use MatLab at the present time.

Again i dont use MatLab, but isnt ode45 made for an initial value problem?
That would mean you specify ONE time value and ONE solution value, not two of each.
First, do you have to solve for 'k' too?
If so, you may be able to just divide through and then solve, then determine 'k' from your two t values and two y values. This will solve the problem of trying to specify two solution values also most likely.

I say the above based on a few searches on the web for ode45 in MatLab.
I use other methods as well as my own version of RKF45 so if you come up with some numerical points i can check them for you.
 

WBahn

Joined Mar 31, 2012
32,829
Hi tspan is my time range , y15 is the value of y at t=15
So how are you conveying that information to your call to ode45(). I see nothing in your call that could possibly do that. At best, I would conclude that the function things it's the value at t=300.
 

MrAl

Joined Jun 17, 2014
13,704
So how are you conveying that information to your call to ode45(). I see nothing in your call that could possibly do that. At best, I would conclude that the function things it's the value at t=300.
Hi,

From what i have seen on the web, it's a regular initial value problem solver and so for first order it would only require one value for y, but you might care to look also and see what you can find out. The function ode45() is found all over the web for MatLab.
The second value could be used later, which i guess you did too.
 
Top