Runge-Cute Method for solving system of differentional equat

The only place for all Non Celestia Discussion/Stuff
Topic author
Terance
Posts: 3
Joined: 17.03.2008
With us: 16 years 10 months

Runge-Cute Method for solving system of differentional equat

Post #1by Terance » 17.03.2008, 19:02

Would you be so kind to change algorithm for solving this system
d2_x/dt_2=-GMx/(x^2+y^2)^(3/2)
d2_y/dy_2=-GMy/(x^2+y^2)^(3/2)

algorithm name is Runge-Cute Method

#include <stdio.h>
#include <stdafx.h>
#include <math.h>
#include <iostream>

using namespace std;
double f(int i,double x,double y[4]){
switch (i){
case 1:return y[4];break;
case 2: return y[1];break;
case 3:return y[2];break;
case 4:return y[3];break;
default : break;
}
}

void step(double x,double h,int n,double y[4])
{
int i=0;
double yt[4];
double k1[4];
double k2[4];
double k3[4];
double k4[4];

for(i = 1; i <= n; i++)
{
k1[i] = h*f(i, x, y);
}
for(i = 1; i <= n; i++)
{
yt[i] = y[i]+0.5*k1[i];
}
for(i = 1; i <= n; i++)
{
k2[i] = h*f(i, x+h*0.5, yt);
}
for(i = 1; i <= n; i++)
{
yt[i] = y[i]+0.5*k2[i];
}
for(i = 1; i <= n; i++)
{
k3[i] = h*f(i, x+h*0.5, yt);
}
for(i = 1; i <= n; i++)
{
yt[i] = y[i]+k3[i];
}
for(i = 1; i <= n; i++)
{
k4[i] = h*f(i, x+h, yt);
}
for(i = 1; i <= n; i++)
{
y[i] = y[i]+(k1[i]+2.0*k2[i]+2.0*k3[i]+k4[i])/6;
}
}

void solvesystemrungekutta(double x,double x1,int steps,double result[4]){

for(int i = 1; i <= steps-1; i++)
{
step(x+i*(x1-x)/steps, (x1-x)/steps,4, result);
}
}

int _tmain(){
//???µ?€???°?

Avatar
t00fri
Developer
Posts: 8772
Joined: 29.03.2002
Age: 22
With us: 22 years 10 months
Location: Hamburg, Germany

Post #2by t00fri » 17.03.2008, 19:54

Just a little math background (can't hurt, can it?):

These equations are called differential equations
and the method you were referring to is by two gentlemen, named

Runge-Kutta

"Runge-Cute" sounds cute, I must admit, yet...

F.
Image

Topic author
Terance
Posts: 3
Joined: 17.03.2008
With us: 16 years 10 months

Post #3by Terance » 18.03.2008, 11:50

t00fri wrote:Just a little math background (can't hurt, can it?):

These equations are called differential equations
and the method you were referring to is by two gentlemen, named

Runge-Kutta

"Runge-Cute" sounds cute, I must admit, yet...

F.

You're right )))))))my english isnt so good/

Avatar
t00fri
Developer
Posts: 8772
Joined: 29.03.2002
Age: 22
With us: 22 years 10 months
Location: Hamburg, Germany

Post #4by t00fri » 18.03.2008, 15:45

Terance wrote:
t00fri wrote:Just a little math background (can't hurt, can it?):

These equations are called differential equations
and the method you were referring to is by two gentlemen, named

Runge-Kutta

"Runge-Cute" sounds cute, I must admit, yet...

F.
You're right )))))))my english isnt so good/


Runge-"Cute" is not a matter of English, since these are names.
It's more a matter of mathematics...

English is also not my mother tongue.


F.
Image

Christophe
Developer
Posts: 944
Joined: 18.07.2002
With us: 22 years 6 months
Location: Lyon (France)

Post #5by Christophe » 18.03.2008, 16:32

t00fri wrote:Runge-"Cute" is not a matter of English, since these are names.
It's more a matter of mathematics...


Famous names are sometimes translated: ? ?…???±?????
Christophe

Avatar
t00fri
Developer
Posts: 8772
Joined: 29.03.2002
Age: 22
With us: 22 years 10 months
Location: Hamburg, Germany

Post #6by t00fri » 18.03.2008, 21:50

Christophe wrote:
t00fri wrote:Runge-"Cute" is not a matter of English, since these are names.
It's more a matter of mathematics...


Famous names are sometimes translated: ? ?…???±?????
Image

Topic author
Terance
Posts: 3
Joined: 17.03.2008
With us: 16 years 10 months

Post #7by Terance » 19.03.2008, 07:34

But my question is still alive ))))Help me to write some code to solve this system

Avatar
t00fri
Developer
Posts: 8772
Joined: 29.03.2002
Age: 22
With us: 22 years 10 months
Location: Hamburg, Germany

Post #8by t00fri » 19.03.2008, 19:21

Terance wrote:But my question is still alive ))))Help me to write some code to solve this system


Sorry no time for such things, as concerns myself. You got to learn doing this yourself, I am afraid.

F.
Image

scaddenp
Posts: 55
Joined: 07.08.2003
With us: 21 years 5 months
Location: Dunedin, New Zealand

Post #9by scaddenp » 19.03.2008, 21:59

Its dangerous to play with these solvers without some understanding of how they work. If you have no background in numerical analysis, then I suggest you start with Numerical Recipes in C++. While the code has limitations, the explanation as to how the beasts work is good. netlib has more complex codes. If you are in difficulties with esoteric equations and problems, then the usenet group sci.math.num-analysis is a good place to ask for help but you really need to have the background first.


Return to “Petit Bistro Entropy”