Runge-Kutta 4th Order Integration help. Watch

KloppOClock
Badges: 14
Rep:
?
#1
Report Thread starter 4 weeks ago
#1
Hi,

I have been given two second order differential equations which I am to convert to a system of four first order differential equations:

Name:  2de.png
Views: 4
Size:  16.2 KB
I then get the following from these:
Attachment 794398794400

I now have to solve these using the runge-kutta first order method.
I am confused as to how to do this, because as far as I am aware, the format that this numerical method can be used on is the form of y'(t)=f(y,t).

my functions instead are such that for example equation 3 is s'(t)=f(z,t). (I have chosen my variable names poorly as that t is not time but just a letter.

my question is when solving the k values using this method, how can i calculate the f(y,t) values given that in my function i dont know how I can use the time value. are my initial system of first order equations wrong and i need to derive a different system or can it be solved ?

thanks
Attached files
0
reply
RDKGames
  • Community Assistant
Badges: 20
Rep:
?
#2
Report 4 weeks ago
#2
(Original post by KloppOClock)
Hi,

I have been given two second order differential equations which I am to convert to a system of four first order differential equations:

I then get the following from these:

I now have to solve these using the runge-kutta first order method.
I am confused as to how to do this, because as far as I am aware, the format that this numerical method can be used on is the form of y'(t)=f(y,t).

my functions instead are such that for example equation 3 is s'(t)=f(z,t). (I have chosen my variable names poorly as that t is not time but just a letter.

my question is when solving the k values using this method, how can i calculate the f(y,t) values given that in my function i dont know how I can use the time value. are my initial system of first order equations wrong and i need to derive a different system or can it be solved ?

thanks
What does \dot{z} denote?? Is it differentiation with respect to t ? If so, isn't it a bit confusing to then define \dot{\phi} = t ?
0
reply
KloppOClock
Badges: 14
Rep:
?
#3
Report Thread starter 4 weeks ago
#3
(Original post by RDKGames)
What does \dot{z} denote?? Is it differentiation with respect to t ? If so, isn't it a bit confusing to then define \dot{\phi} = t ?
yes thats what it means. i chose t as a variable by accident, should have called it something else. all the t's in the equations can be called something else but the differentials are differentiated with respect to time, not that t.
0
reply
KloppOClock
Badges: 14
Rep:
?
#4
Report Thread starter 4 weeks ago
#4
Name:  problemo.png
Views: 5
Size:  49.9 KB

i got functions 3-6 from 1-2. i then have to solve using kutta but they are not of the form y'=f(y,t) as you can see at the end.

can i still solve them using runge - kutta or are my differential equations wrong.
0
reply
DFranklin
Badges: 18
Rep:
?
#5
Report 4 weeks ago
#5
(Original post by KloppOClock)
Name:  problemo.png
Views: 5
Size:  49.9 KB

i got functions 3-6 from 1-2. i then have to solve using kutta but they are not of the form y'=f(y,t) as you can see at the end.

can i still solve them using runge - kutta or are my differential equations wrong.
Is your problem that "you don't know what t is", or that, for example, you have c' = f(c(t), b(t), z(t)) and you were expecting something more like c' = f(c(t))?
0
reply
KloppOClock
Badges: 14
Rep:
?
#6
Report Thread starter 4 weeks ago
#6
(Original post by DFranklin)
Is your problem that "you don't know what t is", or that, for example, you have c' = f(c(t), b(t), z(t)) and you were expecting something more like c' = f(c(t))?
i was expecting to get c' as a function of c(t).

my problem is that i dont know if i can use my equations with this method because im not sure if ive derived the correct ones to use.

also when i work out the k values using this method i need to be able to evaluate c(t+dt) which i dont know how to do if i dont have any time variables in the actual equation or maybe im misunderstanding it
0
reply
RDKGames
  • Community Assistant
Badges: 20
Rep:
?
#7
Report 4 weeks ago
#7
(Original post by KloppOClock)
i was expecting to get c' as a function of c(t).

my problem is that i dont know if i can use my equations with this method because im not sure if ive derived the correct ones to use.

also when i work out the k values using this method i need to be able to evaluate c(t+dt) which i dont know how to do if i dont have any time variables in the actual equation or maybe im misunderstanding it
RK4 is an interative technique, so you iterate from one time to another to yield approximated z, \dot{z}, \phi, \dot{\phi} values.

You don't 'solve' for f(y,t) or whatever it is.

The ODE's here are only dependent on t through z,\phi. It doesn't need to appear explicitly in the ODE's.
0
reply
KloppOClock
Badges: 14
Rep:
?
#8
Report Thread starter 4 weeks ago
#8
(Original post by RDKGames)
RK4 is an interative technique, so you iterate from one time to another to yield approximated z, \dot{z}, \phi, \dot{\phi} values.

You don't 'solve' for f(y,t) or whatever it is.

The ODE's here are only dependent on t through z,\phi. It doesn't need to appear explicitly in the ODE's.
https://en.wikipedia.org/wiki/Runge%...3Kutta_methods

i dont think i understand how to work out the values of k2,k3,k4.

how can i evaluate that function ?
0
reply
DFranklin
Badges: 18
Rep:
?
#9
Report 4 weeks ago
#9
(Original post by KloppOClock)
i was expecting to get c' as a function of c(t).

my problem is that i dont know if i can use my equations with this method because im not sure if ive derived the correct ones to use.

also when i work out the k values using this method i need to be able to evaluate c(t+dt) which i dont know how to do if i dont have any time variables in the actual equation or maybe im misunderstanding it
if there's no t dependence, then f(c, t) = f(c). In other words, just pretend your function f takes a parameter t but doesn't do anything with it.
0
reply
DFranklin
Badges: 18
Rep:
?
#10
Report 4 weeks ago
#10
(Original post by KloppOClock)
https://en.wikipedia.org/wiki/Runge%...3Kutta_methods

i dont think i understand how to work out the values of k2,k3,k4.

how can i evaluate that function ?
Are you happy you know how to find k1?
0
reply
KloppOClock
Badges: 14
Rep:
?
#11
Report Thread starter 4 weeks ago
#11
(Original post by DFranklin)
Are you happy you know how to find k1?
what about my equations when its not c'(t) = c(t)

but like c'(t)= function of c(t),b(t),z(t)
0
reply
DFranklin
Badges: 18
Rep:
?
#12
Report 4 weeks ago
#12
(Original post by KloppOClock)
what about my equations when its not c'(t) = c(t)

but like c'(t)= function of c(t),b(t),z(t)
The simplest way of looking at this is to think of y in the wiki article as being a vector. So here you'd have a vector

y = \begin{pmatrix} z \\ \phi \\ b \\ c \end{pmatrix}, and then y' = F(y), where the 4 components of F are basically the 4 equations (3)-(6) in your post #4. Then the equations in the wiki article still work and still apply (just ignoring t in F(y, t) etc. since our equations are time independent)

Or, on a stricly procedural basis:

if you have c' = f(c, b, z), and assuming you've already calculated c_n, b_n, z_n and want to find c_{n+1} then to find k1 you'd
just calculate h f(c_n, b_n, z_n). (f doesn't depend directly on t, so we just ignore it).

Now, to find k2, you need to have done this for *all* the components you need to evaluate f. That is, you found "k1 for c", but you need to find "k1 for b" and "k1 for z" as well. For clarity, denote these as k_{1, c}, k_{1, b},k_{1, z}.

Then k2 (for c, so k_{2,c} if we wanted to be consistent about notation) is going to be

h f(c_n+\frac{1}{2} k_{1,c}, b_n+\frac{1}{2} k_{1,b}, z_n+\frac{1}{2} k_{1,z})

So you'd find all the k_2, then do something similar to find all the k_3, and then the k_4.

In terms of implementation, you *really* want to get comfortable with the idea of y being a vector, however.
0
reply
KloppOClock
Badges: 14
Rep:
?
#13
Report Thread starter 4 weeks ago
#13
(Original post by DFranklin)
The simplest way of looking at this is to think of y in the wiki article as being a vector. So here you'd have a vector

y = \begin{pmatrix} z \\ \phi \\ b \\ c \end{pmatrix}, and then y' = F(y), where the 4 components of F are basically the 4 equations (3)-(6) in your post #4. Then the equations in the wiki article still work and still apply (just ignoring t in F(y, t) etc. since our equations are time independent)

Or, on a stricly procedural basis:

if you have c' = f(c, b, z), and assuming you've already calculated c_n, b_n, z_n and want to find c_{n+1} then to find k1 you'd
just calculate h f(c_n, b_n, z_n). (f doesn't depend directly on t, so we just ignore it).

Now, to find k2, you need to have done this for *all* the components you need to evaluate f. That is, you found "k1 for c", but you need to find "k1 for b" and "k1 for z" as well. For clarity, denote these as k_{1, c}, k_{1, b},k_{1, z}.

Then k2 (for c, so k_{2,c} if we wanted to be consistent about notation) is going to be

h f(c_n+\frac{1}{2} k_{1,c}, b_n+\frac{1}{2} k_{1,b}, z_n+\frac{1}{2} k_{1,z})

So you'd find all the k_2, then do something similar to find all the k_3, and then the k_4.

In terms of implementation, you *really* want to get comfortable with the idea of y being a vector, however.
this has cleared it up for me so much, thank you xx
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

University open days

  • University of Bath
    Undergraduate Virtual Open Day Undergraduate
    Sat, 23 Feb '19
  • Ravensbourne University London
    School of Design, School of Media Further education
    Sat, 23 Feb '19
  • Leeds Trinity University
    PGCE Open Day Further education
    Sat, 23 Feb '19

Do you have a food intolerance or allergy?

Yes - a food intolerance (45)
12.33%
Yes - a food allergy (39)
10.68%
Yes - an autoimmune disorder (i.e coeliac, colitis) (11)
3.01%
Yes - I have an intolerance and allergy (9)
2.47%
No (261)
71.51%

Watched Threads

View All