My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 3 attachment: rk2.txt (1.0 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <cstdlib>
#include <iostream>

using namespace std;
double abs(double x){
if(x < 0)
return x*(-1);
else
return x;

}
double f(double x)
{
//return(x * x + 2 * x);
//return(1-x*x);
//return(x * x * x - 4 * x * x + 10);
//return(x*x - 5*x +5);
}

double fr(double x, double y)
{
//double f = 10 - x*x +y;
//return (2*x + y*y*x);
return (x);
}


//=================================================================================
int main(int argc, char *argv[])
{



double y = 0;
double H = 0.1;
int ilosc = 3;
double x0 = 0;
double y0 = 2;
y=y0;
for(int i=0;i<=ilosc;i++)
{
double x=x0+(i*H);

double K1 = (fr(x,y));
double K2 = (fr((x + ( H)), (y + K1)));
//double K3 = (fr((x + (0.5 * H)), (y + 0.5 * H * K2)));
//double K4 = (fr((x + H), (y + K3*H)));
//double y = (y + (1/6) * (K1 + 2 * K2 + 2 * K3 + K4));
y =(y + (((K1 + K2)/2)*H));


cout << K1 << endl << K2<<endl ;

cout<<"Wynik: x: "<<x<<" y: "<<y<<endl;

}
system("PAUSE");
return EXIT_SUCCESS;

}

Powered by Google Project Hosting