The wonderful combination of program and music: let us listen to the sound of chaos

In the early 1970s, R. May, an ecologist at Princeton University in the United States, proposed a famous model when studying the reproductive rules of insect populations: χ[n+1]=k*χ[n]*(1-χ[n] Where χ[n] represents the number of the nth generation group. Given an initial χ[0] value and then iterating over and over, it has been found that the resulting sequence χn has many interesting phenomena with the difference in k values. When the k value is between 0 and 1, χ[n] tends to zero after a certain number of iterations. When the k value is between 1 and 3, it tends to 1/k. When the k value is greater than 3, after a certain number of iterations, χ[n] alternates between 2 values, and the value of k increases to around 3.449. The alternating change value becomes four again. Continue to increase the value of k, the number of alternating values ​​of χ[n] is rapidly doubled in the order of 4→8→16→32, and finally chaos. However, when the k value is around 3.835, after a certain number of iterations, χ[n] changes very simply between the three values, and then rapidly increases in the order of 3→6→12. Repeatedly, the surprising complexity is hidden in simple equations.

In order to reflect the infinite mystery of this complexity, the following small program written in TC2.0 uses χ[n] size to control the pronunciation frequency of PC speakers, set different k values, we can hear the sound of chaos . When you execute the following small program, the k value is equivalent to a “tuning knob”. When the k value is set between 1 and 3, only one tone is transmitted from the speaker, which is annoying and repeating. When the k value is slightly greater than 3, it begins to have a rhythm: so-mi-so-mi.... When the k value is increased to 3.449, it becomes so-fa-la-mi-so-fa-la-mi..., and then the k value is increased, the rhythm is more complicated, and finally becomes the music work of the modern abstract composer. But the rhythm is not infinitely complicated as the value of k increases. When the k value is increased to 3.835, the pitch becomes mi-so-TI-mi-so-TI... again, and then increasing the value of k quickly becomes more complicated. Constantly changing the value of k, listening carefully, you will hear the infinite mystery of chaos.

#include

#include

#include

Main()

{

Int fMin=20, fMax=16000; /*fMin represents the lowest frequency, fMax represents the highest frequency*/

Int fDis,i; /*fDis represents the difference between the highest frequency and the lowest frequency, i is used for cyclic counting*/

Float x=0.1,k; /*x represents the size of x[n], and its initial value is set to 0.1, ie x[0]=0.1*/

Char ch;

fDis=fMax-fMin;

Clrscr();

While(1)

{

Printf("Please input The value of k(1-4.0)"); /*Enter k value*/

Printf("If you want to quit,Please input:0"); /*if k=0 exit*/

Scanf("%f",&k);

If (k==0)

{

Break;

}

Else if((k<1)||(k>4.0))

{

Printf("The number must be: 1

conTInue; / / input is wrong, continue to enter.

}

For(i=1;i<100;i++) /*Remove the first 100 points*/

{

x=k*x*(1-x);

}

For (i=1;i<100;i++)

{

x=k*x*(1-x); /*calculate the value of x*/

Sound(x*fDis+20); /*Use the value of x to control the pronunciation frequency of the PC speaker*/

Delay(1000);

If (kbhit())//kbhit() detects if there is a button event, if there is no button, it returns 0;

{

Ch=getch();//Read key value

Switch(ch)

{

Case 27:

Nosound();//close the sound

Return(0);//ESC exit

}

Break;

}

}

Nosound();//close the sound

Clrscr();//clear screen

}

Nosound();

Return(0);

}

High Frequency Power Supply Transformer

EE 30 abb transformer,RM6 frequency transformer,ETD44 power transformer,EFD20 high frequency transformer

IHUA INDUSTRIES CO.,LTD. , https://www.ihua-coil.com

Posted on