Coupled First Order Equations

In summary, The problem involves taking a second-order differential equation and reexpressing it into coupled first-order equations. This can be done by changing the variables and setting up a system of two first-order equations. The Runge Kutta method can then be applied to solve the system and approximate the numerical solution. It is important to correctly set up the stage constants for the iteration in order to solve for both variables.
  • #1
Jwill
39
0

Homework Statement


I have a large project involving Runge Kutta numerical solutions of differential equations. I understand the Runge Kutta method and I've done it before, but my problem involves taking the differential equation

y''=sin(3y(t)), t>=0

and reexpressing this IVP into coupled first order equations. I have seen examples where people have done something similar like set

z'=sin(3y(t))
y'=z

and there is a guy in my class that swears that this is right, but frankly that doesn't make sense to me in this case. If someone could help me understand how to do this correctly, I feel like I have a decent understanding of the numerical solution method. I have been asked to use the first order Runge Kutta method, but I have never used this method with coupled equations that looks anything like this...


Homework Equations


y''=sin(3y(t)), t>=0


The Attempt at a Solution


Matlab Code:
clc;
clear all;
close all;
format long g;

N=input('current value of N')
deltat=20./N;
y=1;
z=0;
h = deltat;
t = 0:h:20;
i=0;

for i = 1:length(t)
T(i) = i*h;
Y(i) = y;
k1 = (z);
l1 = sin(3.*(y));
k2 = ((z)+(h./2).*l1);
l2 = sin(3.*((y)+(h./2).*k1));
k3 = ((z)+(h./2).*l2);
l3 = sin(3.*((y)+(h./2).*k2));
k4 = ((z)+h.*l3);
l4 = sin(3.*(y+h.*k3));
z = z + (h./6).*(l1+2.*l2+2.*l3+l4);
y = y + (h./6).*(k1+2.*k2+2.*k3+k4);
end

Y = Y'

plot(T,Y);
 
Physics news on Phys.org
  • #2
Mathematical way to do it is:

change the parameters so:
u=y
v=y'

u'=v : first 1st order equation.

v'=sin(3*u) : second 1st order equation.now you have a system of two 1st order differentials equations.
it's done basically by a change of variables :)
 
  • #3
Can someone tell me how to solve this differential equation in MATLAB so that I can check my numerical solution? (I'm not asking for an answer, just a way to check my answer)
 
  • #4
Look up the help docs for ODE45/23/etc for a way to solve this in matlab. You will find all the examples convert the second order diff eq to two first order or even three. You already have what you need to pretty much copy and paste MATLAB example code and run your problem. This in control theory is described as the 'state space representation'.

What that friend of yours is doing is converting the second order diff eq, to two first order diff eqs (as gomunk51 already mentioned). Then it's easy to convert things to the RK4 form. You also have a couple of other varieties of RK which do the job based on your requirement for accuracy, precision and time-to-run. See Kreyszig-Engg math. You also have the modified RungeKutta-Nystrom method described there, which generalizes the standard RK method to apply to a second order ODEs

A bit of MATLAB advice: 1. Don't post code online, no one wants to shift through your code (neither do your instructors) 2. Don't use vector operations (the hadamard dot) on scalars. 3. By declaring your Y(i) before you calculate the i^th y, you are losing your last calculation. (Not a problem for your case) 4. Such coupled differential equations are best solved as arrays, (don't worry about this right now) 5. Indent your code (select all, then press ctrl+I in MATLAB editor)

What you have done looks all right, but I don't remember rk4 in detail.
 
  • #5
If these equations are correct then I must not understand how to do the stage constants for the iteration.

If
[tex]\frac{dz}{dt} = sin(3y(t)) [/tex]

[tex]\frac{dy}{dt} = z [/tex]

then

[tex]\frac{dz}{dt} = f[t, y(t)] [/tex]

[tex]\frac{dy}{dt} = f[t, z(t)] [/tex]

(I think)

How are they "coupled" in that I don't see that they have a dependency on each other. I understand the runge kutta method when they have a dependency on each other, but how does solving for z or y help you solve for the other?... I don't see how the stage constants rely on each other.

I would understand if it was

[tex]\frac{dy}{dt} = f[t, y(t), z(t)] [/tex]

[tex]\frac{dz}{dt} = F[t, y(t), z(t)] [/tex]

If you could help me understand this, I'd appreciate it. It would make since if y and z were in both first order equations.
 
  • #6
Well... anyway my attempt at this was:

[tex]k1 = z_{i}[/tex]

[tex]l1 = sin(3.*(y_{i}));[/tex]

[tex]k2 = z_{i}+\frac{h}{2}*l1[/tex]

[tex]l2 = sin(3*(y_{i}+\frac{h}{2}*k1))[/tex]

[tex]k3 = z_{i}+\frac{h}{2}*l2[/tex]

[tex]l3 = sin(3*(y_{i}+\frac{h}{2}*k2))[/tex]

[tex]k4 = z_{i}+h*l2[/tex]

[tex]l4 = sin(3*(y_{i}+h*k2))[/tex]

[tex]z_{i+1} = z_{i} + \frac{h}{6}*(l1+2*l2+2*l3+l4)[/tex]

[tex]y_{i+1} = y_{i} + \frac{h}{6}*(k1+2*k2+2*k3+k4)[/tex]

I doubt this is correct... In the event that it is, could someone explain it to me better. Either way, I would like to understand this.
 
  • #7
Jwill said:
If these equations are correct then I must not understand how to do the stage constants for the iteration.

If
[tex]\frac{dz}{dt} = sin(3y(t)) [/tex]

[tex]\frac{dy}{dt} = z [/tex]

then

[tex]\frac{dz}{dt} = f[t, y(t)] [/tex]

[tex]\frac{dy}{dt} = f[t, z(t)] [/tex]

(I think)
No, this is incorrect.

How are they "coupled" in that I don't see that they have a dependency on each other. I understand the runge kutta method when they have a dependency on each other, but how does solving for z or y help you solve for the other?... I don't see how the stage constants rely on each other.

I would understand if it was

[tex]\frac{dy}{dt} = f[t, y(t), z(t)] [/tex]

[tex]\frac{dz}{dt} = F[t, y(t), z(t)] [/tex]
This is correct.


If you could help me understand this, I'd appreciate it. It would make since if y and z were in both first order equations.
 
  • #8
Okay. I might be on to something with this:

[tex]u = y [/tex]

[tex]v = y' [/tex]

[tex]v' = sin(3u) [/tex]

[tex]u' = \frac{-1}{3v} cos(3u) [/tex]

This way it's in the form:

[tex]\frac{dv}{dt} = f [/tex]

[tex]\frac{du}{dt} = F[v, u] [/tex]

So... during runge kutta iterations, I'd have to solve for v to solve for u for each iteration.

Is this on the right track? It makes more sense to me anyway... assuming I did the itegration right. I'm not sure if or how I'd do anything with time t though in the stage constants.
 
  • #9
Actually, I'm sure that

[tex]u' = \frac{-1}{3v} cos(3u) [/tex]

is not correct. When I differentiate it, it does not work out to be the original equation. What method of integration would be used to solve it? I'm sure it's integrated over time and v and u are functions of time.
 
  • #10
When you said that the two first order functions were incorrect... I am confused because you said that was correct earlier. I am confused and not sure what to do. I don't see how one could use the runge kutta method with those functions.

I am under the impression that in many cases when you use runge kutta, you integration a high order function and form two functions of 2 or 3 variables.

It feels like if I took the function and integrated it and used both of these to solve each equation simultaneously, I could come out with an answer for y. What I tried to do sort of makes sense, but I don't think the integral is right. Any guidance is much appreciated.
 

1. What are coupled first order equations?

Coupled first order equations refer to a system of two or more first-order differential equations that are connected or "coupled" to each other. This means that the variables in each equation are dependent on one another.

2. How do coupled first order equations differ from uncoupled first order equations?

In uncoupled first order equations, each equation is independent and does not affect or depend on the other equations in the system. In contrast, coupled first order equations are interdependent and have a direct influence on one another.

3. What are some real-life applications of coupled first order equations?

Coupled first order equations are commonly used in fields such as physics, engineering, and biology to model systems that involve multiple interacting variables. Examples of real-life applications include chemical reactions, circuit analysis, and population dynamics.

4. How are coupled first order equations solved?

The most common method for solving coupled first order equations is through numerical methods, such as Euler's method or Runge-Kutta methods. These methods approximate the solutions by breaking down the equations into smaller, simpler steps that can be solved using algebraic or numerical techniques.

5. What are some challenges in solving coupled first order equations?

One of the main challenges in solving coupled first order equations is the complexity of the system and the potential for the equations to become stiff, meaning they are difficult to solve due to large differences in the timescales of the variables. Additionally, finding initial conditions that satisfy all of the equations can also be a challenge.

Similar threads

  • Calculus and Beyond Homework Help
Replies
2
Views
223
  • Calculus and Beyond Homework Help
Replies
2
Views
858
  • Calculus and Beyond Homework Help
Replies
6
Views
794
  • Calculus and Beyond Homework Help
Replies
8
Views
348
  • Calculus and Beyond Homework Help
Replies
3
Views
515
  • Calculus and Beyond Homework Help
Replies
7
Views
643
  • Calculus and Beyond Homework Help
Replies
5
Views
1K
  • Calculus and Beyond Homework Help
Replies
12
Views
1K
  • Programming and Computer Science
Replies
15
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
493
Back
Top