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
2
attachment: sieczne.cpp
(1.1 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
#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 = x*x*x - 4*x*x + 10;
return f;
}
//=================================================================================
int main(int argc, char *argv[])
{
//w siecznych nie ma a i b!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// double b = System::Convert::ToDouble(textBox4->Text);
//double a = System::Convert::ToDouble(textBox3->Text);
double wynik;
double x0 = 0;
double x1 = 1;
double eps = 0.2;
//double x;
//
//while (abs(f(x1))>eps)
//{
//
//x=x1- ((x1-x0)/f(x1)-f(x0))*f(x1);
//x1=x;
//x0=x1;
//}
while (abs(f(x1))>eps)
{
double x=x0;
x0=x1;
if (f(x1)==f(x)) cout<< "blad";
x=x1-(f(x1)/(f(x1)-f(x)))*(x1-x);
x1=x;
}
cout<<"Wynik: "<< x1 <<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
Powered by
Google Project Hosting