My favorites
▼
|
Sign in
nmcalc
projekt na inzynierie oprogramowania
Project Home
Downloads
Wiki
Issues
Source
READ-ONLY: This project has been
archived
. For more information see
this post
.
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
3
attachment: am.txt
(1.3 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <cstdlib>
#include <iostream>
using namespace std;
double abs(double x){
if(x < 0)
return x*(-1);
else
return x;
}
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<=0;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;
double c, p; //predicotr i corrector
for (int i=1; i<=ilosc; i++)
{
x=x0+(i*H);
p = y + (H * ( (3 * fr(x,y) - fr(x0, y0))/2));
c = y + (H * ( (fr(x,y) + fr((x + H), p))/2));
y0=y;
y=c;
x0=x;
cout << "P: " << p << " C: " << c <<endl;
};
}
system("PAUSE");
return EXIT_SUCCESS;
}
Powered by
Google Project Hosting