| Back to Logistic Map |


/*
Author: Jeff Sale
2/14/97
Java Applet to Plot Bifurcation Map of Logistic Model of Population Dynamics
My first java applet
*/

import java.awt.Graphics;

import java.awt.Color;

 

public class LogisticApplet extends java.applet.Applet {

 

double f1(double x) {

return 1-x;

}

 

public void paint(Graphics g) {

int x1, y1, x2, y2;

double r = 3.5;

double nextr = 0.0;

double nextx = 0.5, thisx = 0.5; // variables x(i+1) and x(i)

double xscale = 0.020;

double yscale = 0.9*size().height;

int xmax = 50*size().width-10;

double sizewidth = size().width*1.0;

Color blue, white;

 

g.setColor(Color.white);

g.fillRect(0,0,size().width,size().height);

g.setColor(Color.blue);

for (int x = 1 ; x < xmax ; x++) {

nextx = (r+nextr)*thisx*(1-thisx);

thisx = nextx;

nextr = nextr+0.010/sizewidth;

x1 = (int)(xscale*x);

y1 = (int)(1.0*yscale*thisx);

x2 = x1;

y2 = y1;

g.drawLine(x1, y1, x2, y2);

}

}

}