KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > chaos > LogisticMap


1 package JSci.maths.chaos;
2
3 import JSci.maths.*;
4
5 /**
6 * The LogisticMap class provides an object that encapsulates the logistic map.
7 * x<sub>n+1</sub> = r x<sub>n</sub> (1-x<sub>n</sub>)
8 * @version 1.0
9 * @author Mark Hale
10 */

11 public final class LogisticMap extends Object JavaDoc implements Mapping {
12         private final double r;
13         /**
14         * 2-cycle bifurcation point.
15         */

16         public final static double R_2CYCLE=3.0;
17         /**
18         * 4-cycle bifurcation point.
19         */

20         public final static double R_4CYCLE=1.0+Math.sqrt(6.0);
21         /**
22         * 8-cycle bifurcation point.
23         */

24         public final static double R_8CYCLE=3.544090;
25         /**
26         * 16-cycle bifurcation point.
27         */

28         public final static double R_16CYCLE=3.564407;
29         /**
30         * Accumulation point.
31         */

32         public final static double R_ACCUMULATION=3.569945672;
33         /**
34         * Constructs a logistic map.
35         * @param rval the value of the r parameter
36         */

37         public LogisticMap(double rval) {
38                 r=rval;
39         }
40         /**
41         * Performs the mapping.
42         * @param x a double
43         */

44         public double map(double x) {
45                 return r*x*(1.0-x);
46         }
47         public double hausdorffDimension() {
48                 return 0.538;
49         }
50         /**
51         * Iterates the map.
52         * @param n the number of iterations
53         * @param x the initial value
54         */

55         public double iterate(int n,double x) {
56                 for(int i=0;i<n;i++)
57                         x=map(x);
58                 return x;
59         }
60 }
61
62
Popular Tags