Solving Second Order Differential Equations using Runge Kutta

In summary: Can you help?In summary, an expert summarizer of content provided the following summary: Homework Equations states that y''+2xy'=0 and provides an equation for y' at x=0. They also provided code for a MATLAB program to calculate y' at x=0.
  • #1
narayanjr
3
0

Homework Statement


In aerodynamics, one encounters the following initial value problem for Airy’s equations:

y''(x) + xy = 0, y(0) = 1, y'(0) = 0

Using the Runge-Kutta method with h=0.005 and determine values between x=0 and x=10 sufficient to sketch the relationship.



Homework Equations


y''(x) + xy = 0, y(0) = 1, y'(0) = 0
I think,
k1 = h*f(Xn, Yn)
k2 = h*f(Xn+h/2, Yn+k1/2)
k3 = h*f(Xn+h/2, Yn+k2/2)
k4 = h*f(Xn + h, Yn + k3)

The Attempt at a Solution


From what I have read you can't do second order ODE using runge kutta without breaking it into a system of first order ODEs so that's what I tried.

I tried:
d2y/dx2 + xy = 0

dy/dx = z, y(0) = 1

dz/dx + xy = 0

dz/dx = -xy, z(0) = 0

I don't know if that is right or not and if it is I have no idea where to go from here.

Thanks for any help.
 
Physics news on Phys.org
  • #2
Have you ever used mathcad? It has a very easy to use RK function. First, however, you do need to reduce the order and define your system of DE's.
 
  • #3
narayanjr said:

Homework Statement


In aerodynamics, one encounters the following initial value problem for Airy’s equations:

y''(x) + xy = 0, y(0) = 1, y'(0) = 0

Using the Runge-Kutta method with h=0.005 and determine values between x=0 and x=10 sufficient to sketch the relationship.



Homework Equations


y''(x) + xy = 0, y(0) = 1, y'(0) = 0
I think,
k1 = h*f(Xn, Yn)
k2 = h*f(Xn+h/2, Yn+k1/2)
k3 = h*f(Xn+h/2, Yn+k2/2)
k4 = h*f(Xn + h, Yn + k3)

The Attempt at a Solution


From what I have read you can't do second order ODE using runge kutta without breaking it into a system of first order ODEs so that's what I tried.

I tried:
d2y/dx2 + xy = 0

dy/dx = z, y(0) = 1

dz/dx + xy = 0

dz/dx = -xy, z(0) = 0
Yes, that's correct. Now use two simultaneous Runge-Kutta calculations where, at each step, you calculate the values for both y and z and use both in the calculations for the next step.

I don't know if that is right or not and if it is I have no idea where to go from here.

Thanks for any help.
 
  • #4
narayanjr said:
From what I have read you can't do second order ODE using runge kutta without breaking it into a system of first order ODEs so that's what I tried.

I tried:
d2y/dx2 + xy = 0

dy/dx = z, y(0) = 1

dz/dx + xy = 0

dz/dx = -xy, z(0) = 0

I don't know if that is right or not and if it is I have no idea where to go from here.

Thanks for any help.
There is nothing in the Runge Kutta formalism that precludes using on a vector as opposed to a scalar. For example (note well: This is not your problem), suppose

[tex]\frac{d\vec x}{dt} = A \vec x\,, \quad\vec x(0) = \vec x_0[/tex]

where [itex]\vec x[/itex] is some n-vector, A is a constant n-by-n matrix, and x0 is the initial (vectorial) value.

The Runge Kutta equations can be used to numerically this problem.

Back to your problem: Create a 2-vector, I'll call it u, that comprises your y and its derivative:

[tex]\begin{aligned}
z &\equiv \frac{dy}{dx} \\[6 pt]
\vec u &= \bmatrix y \\ z\endbmatrix
\end{aligned}[/tex]

You have already derived that [itex]dy/dx = z, y(0) = 1[/itex] and [itex]dz/dx = -xy, z(0) = 0[/itex]. From these, can you come up with an expression for the initial value of the vector u and the derivative of the vector u with respect to x?
 
  • #5
I am doing this all in MATLAB, This is what I have come up with but I am not sure if this is correct or not.

Attached are my MATLAB code, a Graph of the results, and an excel sheet of all results.
It is zipped because it was to big otherwise. the MATLAB code can be opened in notepad.

Thanks for any help.
 

Attachments

  • MEA Proj.zip
    81.1 KB · Views: 1,007
  • #6
Yes, your approach is right.

d2y/dx2 + xy = 0

dy/dx = z -------------------(1)

dz/dx = -xy -----------------(2)


y' = z, then define
y(n+1) = y(n) + (h/6)*(k1 + 2*k2 + 2*k3 +k4)

and for,
z' = -xy, define,
z(n+1) = z(n) + (h/6)*(j1 + 2*j2 + 2*j3 +j4)

now define k1 , k2 , k3 , k4 and j1 , j2 , j3 , j4

k1 = z
j1 = -x*y

k2 = z + 0.5 * j1
j2 = -( x + 0 .5 * h ) *(y + 0.5 * k1)

k3 = z + 0.5 * j2
j3 = -( x + 0 .5 * h ) *(y + 0.5 * k2)

k4 = z + j2
j4 = -( x + h ) *(y + k2)
 
  • #7
I have a similar problem with Runge Kutta with y''+2xy'=0 given boundary conditions are y=1 at x=0 and y=0 at x=infinity. I am not able to understand how to transform the second boundary condition (i.e.y=0 at x=infinity) to find a definitive value of y' at x=0.
 

1. What is a second order differential equation?

A second order differential equation is a mathematical equation that involves a function, its first derivative, and its second derivative. It is commonly used to model various physical phenomena in science and engineering.

2. What is Runge Kutta method?

Runge Kutta method is a numerical method for solving ordinary differential equations. It is a popular method due to its high accuracy and efficiency in solving complex equations.

3. How does Runge Kutta method work?

Runge Kutta method works by using a series of approximations to estimate the solution of a differential equation. It involves calculating intermediate values of the function, which are then used to determine the final solution.

4. What are the advantages of using Runge Kutta method?

Some of the advantages of using Runge Kutta method include its high accuracy, ability to handle complex equations, and its versatility in solving different types of differential equations. It is also relatively simple to implement and requires minimal computational resources.

5. Are there any limitations of using Runge Kutta method?

One limitation of Runge Kutta method is that it can be computationally expensive for very large systems of equations. It can also be prone to numerical errors if the step size is too large. Additionally, it may not be suitable for solving stiff differential equations, which require different methods for accurate solutions.

Similar threads

  • Calculus and Beyond Homework Help
Replies
1
Views
2K
  • Calculus and Beyond Homework Help
Replies
14
Views
235
  • Calculus and Beyond Homework Help
Replies
14
Views
2K
  • Calculus and Beyond Homework Help
Replies
21
Views
754
  • Calculus and Beyond Homework Help
Replies
12
Views
2K
  • Calculus and Beyond Homework Help
Replies
6
Views
793
  • Programming and Computer Science
Replies
15
Views
2K
  • Calculus and Beyond Homework Help
Replies
5
Views
859
  • Calculus and Beyond Homework Help
Replies
33
Views
3K
  • Calculus and Beyond Homework Help
Replies
8
Views
709
Back
Top