-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
35 lines (30 loc) · 967 Bytes
/
main.cpp
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
#include "MathUtils.h"
#include "gnuplot.h"
#include "DataType.h"
#include "transform.h"
#include "climits"
inline double LogisticEquation(double xn, double r);
inline double LogisticIterator(int n,double x0,double r,double (*LogisticEquation)(double xn,double n));
int main(){
Calculus::SingleVar::Sampler<double,double>::SampledFunction s;;
for(double r =0 ;r<=4;r+=0.0001){
for (int i = 100; i < 170; i++) {
s.y.push_back(LogisticIterator(i,0.01,r,LogisticEquation));
s.x.push_back(r);
}
}
plt::TwoDim::DataPlot2D(s.x,s.y,"w p pt 7 ps 0.1 ","plot ");
return 0;
}
double LogisticEquation(double xn, double r){
return r*xn*(1-xn);
};
inline double LogisticIterator(int n,double x0,double r,double (*LogisticEquation)(double xn,double r)){
double xn = x0;
double xn_p1;
for (int i = 1; i <= n; ++i) {
xn_p1 = LogisticEquation(xn,r);
xn = xn_p1;
}
return xn_p1;
}