Finding Approximate Solutions using the Runge-Kutta Method

Click For Summary
SUMMARY

The forum discussion centers on using the Runge-Kutta method, specifically RK2, to solve the initial-value problem y' + (x^2)y = sin(xy) with y(1) = π and a step size of h = 0.2. Participants calculated approximate values for y1 and y2, with results varying from 2.4669 and 1.76101 to the book's answers of 2.475605264 and 1.825992433. The discrepancy suggests that the book may be using a more accurate method, possibly RK4. The correct formula for RK2 was confirmed, and users were advised to use radians in their calculations.

PREREQUISITES
  • Understanding of the Runge-Kutta methods, specifically RK2 and RK4.
  • Familiarity with initial-value problems in differential equations.
  • Basic proficiency in using mathematical software like Maple or OpenOffice Calc.
  • Knowledge of trigonometric functions and their modes (radians vs. degrees).
NEXT STEPS
  • Learn the differences between RK2 and RK4 methods for solving differential equations.
  • Explore the implementation of the Runge-Kutta method in Maple or Python.
  • Investigate the effects of varying step sizes on the accuracy of numerical solutions.
  • Study the application of the Runge-Kutta method to other types of differential equations.
USEFUL FOR

Students and educators in mathematics, particularly those studying numerical methods for solving differential equations, as well as software developers implementing these methods in programming environments.

Math10
Messages
301
Reaction score
0

Homework Statement


Use the Runge-Kutta method to find approximate values of the solution of the initial-value problem y'+(x^2)y=sin xy, y(1)=pi; h=0.2 at the points xi=x0+ih, where x0 is the point where the initial condition is imposed and I=1, 2.

Homework Equations


yn+1=yn+hf(xn+1/2h, yn+(1/2)hf(xn, yn))
f(x, y)=sin xy-(x^2)y
h=0.2, x0=1, y0=pi.

The Attempt at a Solution


y1=pi+0.2f(1+0.1, pi+0.1f(1, pi))
=pi+0.2f(1.1, 2.83291)
=2.4669

y2=2.4669+0.2f(1.3, 2.4669+0.1f(1.2, 2.4669))
=2.4669+0.2f(1.3, 2.11683)
=1.76101

But the answer is:
y1=2.475605264, y2=1.825992433.
I got y1=2.4669 and y2=1.76101.
Which is the correct answer? Mine or the book's answer? If I'm wrong, please correct me.
 
Physics news on Phys.org
Math10 said:

Homework Statement


Use the Runge-Kutta method to find approximate values of the solution of the initial-value problem y'+(x^2)y=sin xy, y(1)=pi; h=0.2 at the points xi=x0+ih, where x0 is the point where the initial condition is imposed and I=1, 2.

Homework Equations


yn+1=yn+hf(xn+1/2h, yn+(1/2)hf(xn, yn))
Does that formula mean$$y_{n+1} = y_n + hf(x_n + \frac h 2,y_n + \frac h 2f(x_n,y_n))\text{?}$$
 
Using RK2 and OpenOffice Calc, I get y1=2.4636, y2 =1.8181, which are closer to your answers than to the book's.
However, if I cut the step size to 0.1 and, correspondingly, look at y2, y4 I get nearly the book answers: 2.4734, 1.8247.
This suggests the book is using a more accurate method than RK2 with step size 0.2 Maybe it uses RK4 with step size 0.2 - I haven't tried that.
 
@LCKurtz , yes, that's the right formula that I'm using.
 
LCKurtz said:
Does that formula mean$$y_{n+1} = y_n + hf(x_n + \frac h 2,y_n + \frac h 2f(x_n,y_n))\text{?}$$

Math10 said:
@LCKurtz , yes, that's the right formula that I'm using.

OK. I put that formula in Maple and I get: ##(x_1,y_1)= (1.2, 2.463635926),~(x_2,y_2) = (1.4, 1.818074242)## which agree with Haruspex's results.
 
  • Like
Likes Math10
So which answer is right? The book's answer or yours?
 
By the way, do I need to set the mode to radians or degrees on my calc?
 
What's RK2 and RK4?
 
All I can tell you for sure, is that using the formula you gave us, both Haruspex and I get identical answers independently. I doubt we are both wrong. And, speaking for myself, I am assuming the formula you gave is the appropriate one. If it isn't, all bets are off.
 
  • Like
Likes Math10
  • #10
Math10 said:
By the way, do I need to set the mode to radians or degrees on my calc?
Radians, of course!
 
  • Like
Likes Math10
  • #12
LCKurtz said:
I am assuming the formula you gave is the appropriate one
It is RK2.
 
  • Like
Likes Math10
  • #13
Thank you guys for the help!
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
51K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 65 ·
3
Replies
65
Views
8K
Replies
6
Views
2K
  • · Replies 2 ·
Replies
2
Views
5K