Page 1 of 1

Runge-Cute Method for solving system of differentional equat

Posted: 17.03.2008, 19:02
by Terance
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(){
//???µ?€???°?

Posted: 17.03.2008, 19:54
by t00fri
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.

Posted: 18.03.2008, 11:50
by Terance
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/

Posted: 18.03.2008, 15:45
by t00fri
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.

Posted: 18.03.2008, 16:32
by Christophe
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: ? ?…???±?????

Posted: 18.03.2008, 21:50
by t00fri
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: ? ?…???±?????

Posted: 19.03.2008, 07:34
by Terance
But my question is still alive ))))Help me to write some code to solve this system

Posted: 19.03.2008, 19:21
by t00fri
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.

Posted: 19.03.2008, 21:59
by scaddenp
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.