Feigen

Logistic Function

The image displays the bifurcation diagram of the logistic function:

x_{n+1}=r*x_n(x_n-1)

The logistic function is a non-linear, one dimension and discrete equation that with different r values can lead to a stable fixed point, a periodic behavior, or a chaotic solution. The bifurcation diagram using one-dimensional map characterizes all dynamic systems of the same nature, as the Lorenz system, fundamental in chaos theory.

The logistic function and its bifurcation diagram may be defined by a C function with two variables: r and x. Its library:

#include < stdio.h >
#include < math.h >
#include < stdlib.h >
#include "libguardaimagen.h"

Being “”libguardaimagen.h” :

#ifndef _LIBGUARDAIMAGEN_H_
#define _LIBGUARDAIMAGEN_H_

#include < stdio.h >
#include < stdlib.h >
#include < math.h > 

void guardaPGMi(char* nombre, int anchura, 
                int altura, int *pixels, 
                int pixel_min, int pixel_max);

void guardaPGMd(char* nombre, int anchura, 
                int altura, double *pixels, 
                double pixel_min, double pixel_max);

#endif

The code will have as a local function:

double logistica(double r, double x)
{
	x=r*x*(1-x);
	return x;
}

An the main function:

int main(int argc, char **argv) 
{ 
int i, j, n, m, count; 
double x, r, rINI, rFIN, xi, xmax, 
xmin, s[MAXCUENTAS]; 
double f[ALTURA][ANCHURA]; 
rINI=atof(argv[1]); 
if(rINI4) 
{ 
rFIN=4; 
} 
x=0.5; 
for(m=0;m < MAXCUENTAS;m++) 
{ 
x=logistica(rFIN,x); 
s[m]=x; 
} 
xmin=s[0]; 
xmax=s[0]; 
for(m=0;m < MAXCUENTAS;m++) 
{ 
if(xmin > s[m]) 
{ 
xmin=s[m]; 
} 
if(xmax < s[m]) 
{ xmax=s[m]; 
} 
} 
printf ("xmax %0.8f xmin %0.8f r inicial %0.8f r final %0.8fn",
 xmax, xmin, muINI, muFIN); 

In the final part you have to run the logistic function adding every time a pixel falls in a predetermined range