# Iterated Function_r_sin_pi_x_2

### Tags

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.1 • Viewed 119 times • Downloaded 4 times • Run 0 times

## WHAT IS IT?

This is a model of an iterated function f(x) = r * sin ( pi * x / 2 ), a nonlinear recurrence relation that can exemplify some key concepts of chaos theory applied to dynamical systems.

## HOW IT WORKS

Mathematically, iteration refer to the process of iterating a function i.e. applying a function repeatedly, using the output from one iteration as the input to the next. Iteration of apparently simple functions can produce complex behaviors. Some simple iterated functions can be presented as an archetypal example of how complex, chaotic behavior can arise from a simple non-linear dynamical equations.

In this model the function f(x) = r * sin ( pi * x / 2 ) is being iterated starting with X0 (for the first iteration known as initial condition), a number between '0' and '15'. The values of interest for the parameter r are those in the interval [1, 114] (suggested things for the user to notice while running the model).

The model is intended to visualize the behavior of a system described by the function f(x) = r * sin ( pi * x / 2 ) by plotting the iterated function values and generating a final-state diagram.

Every time-step (tick) an iteration is performed with the result plotted on the time-series plot and a point is generated (i.e. a red color turtle is created). The last 10% of turtles are placed/plotted on the final state diagram.

Running the model after inputting different values for the initial condition (X0) and for the r-parameter one can observe that different r values can finally lead to dramatically different long-term behavior, visualized by the time-series plot and final-state diagram (e.g. tend to zero, or a fixed point, exhibiting periodic oscillations, or chaotic behavior).

## HOW TO USE IT

* Input the X0 (initial condition value), either by the respective slider or by input-box below the slider

* Input r - parameter by slider or input-box

* Select and input the number of iterations (by slider or input-box)

Press the SETUP button, then press the GO button to run the model.

Observe the plot and final-state diagram below it.

## THINGS TO NOTICE

System behavior greatly depend on r value:

* With r between 0.1 and 17: tends to "0"

* With r above 17 and up to 35: diverges from '0' and tends to a fixed point close to but above "0"

* For r above 35: the 'divergence from 0' increases and close to 55 this fixed point tends to r value (e.g r=56 -> 55.96; r=57 ->56.99; r=59 -> 58.94)

* Starting with r around 60 up to 82.5: fluctuates close to r tending to a fixed point (below r)

* With r = 82.5 - 95: period 2 oscillations with an increasing amplitude

* For r beyond 95: period 4 oscillations until r=98, when the doubling cascade continues with period 8 oscillations, etc.

* An r-value over approximately 99 is the beginning of chaos

## THINGS TO TRY

Set r=107 and observe the system behavior on the plot and final state-diagram. Then do the same with several r-values between 107.5 and 108.5, then for r=109. What do you observe? How can you call this phenomenon?

If you want to see the values for all the iterations, type in the command line (at the bottom of the GUI window, to the right of ' observer > ' ) the command: show mylist

## EXTENDING THE MODEL

Although in this model all iterations are visible on the plot, the results of the first 90% iterations are skipped (i.e. not plotted on the phase-line below the plot). This is a ‘built in’ automatic procedure. In some cases for a better visualization it may be appropriate to set number of iterations to be skipped ‘manually’.

This model deals with r-values below 114. Since the behavior of this function (i.e. f(x)=r*sin(pi*x/2)) can be in some aspects unique for r > 114 (e.g. r between 168 and 191) an interesting extension by increasing r-range beyond 114.

## NETLOGO FEATURES

This simple model is created in NetLogo and the final state diagram is generated by agents/turtles with coordinates from the list of values produced during function iterations. In order to focus on the final iterations, turtles are created only for the last 10% of iterations.

## RELATED MODELS

This model is part of a suit of models created to visualize some key concepts of Chaos Theory and Dynamical Systems. Most of the models are available on http://modelingcommons.org/account/models/2495

Of a special interest can be the models describing:

* Iterated logistic function (with a final state-diagram) and

* Bifurcation diagram for f(x) = r * sin ( pi * x / 2 )

More insights can be obtained comparing the behavior of the same function f(x) = r * sin ( pi * x / 2 ) for different r-values, as described by the actual model and the bifurcation diagram model.

## CREDITS AND REFERENCES

This simple abstract model was developed by Victor Iapascurta, MD. At time of development he was in the Department of Anesthesia and Intensive Care at University of Medicine and Pharmacy in Chisinau, Moldova / ICU at City Emergency Hospital in Chisinau. Please email any questions or comments to viapascurta@yahoo.com

The model was created in NetLogo 6.0.1, Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

It was inspired by Introduction to Dynamical Systems and Chaos (Fall, 2017) MOOC by David Feldman @ Complexity Explorer (https://www.complexityexplorer.org/courses)

Click to Run Model

```globals [    ;; setting globals for model
mylist
axis
]

breed [ axis-turtles axis-turtle ]   ;; these are turtles as part (i.e. axes tips) of X and Y axes
breed [ m-turtles m-turtle ]         ;; thes are turtles to be plotted on the final-state diagram

patches-own [    ;; properties of patches used to generate the coordinates axes
alpha
omega
]

to setup
ca
set mylist list (0) (X0)  ;; setting the intial list of values
create-axis               ;; to be iterated by logistic function
setup-alpha               ;; setting components of X and Y axes
setup-omega

reset-ticks
end

to go                                   ;; this is the procedure of iteration

set mylist lput result mylist         ;; procedure of iteration where the results are added to a list
if ticks >= Num-iterations [ stop ]   ;; and a new turtle of red color is created with every iteration
;; result of the iteration serves as x-coordinates for this turtle
create-m-turtles 1 [                    ;; according to which it is plotted on final state diagram
set color red
set shape "circle"
set size 5
setxy (last mylist * 400 / r-parameter ) (0)
]

if ticks <= (num-iterations) / 1.1     ;; only last 10% of turtles are plotted
tick
end

to-report result                                    ;; reporter describing the
report  r-parameter * sin( pi * last mylist / 2)  ;; iteration procedure based
end                                                  ;; on previous iteration result

to create-axis                                         ;; creating X and Y axes
ask patches with [ pycor = 0 ] [ set pcolor white ]
create-axis-turtles 1 [
set color yellow
set size 8
setxy 0 0
]
create-axis-turtles 1 [
set color yellow
set size 8
setxy 400 0
]
end

to setup-alpha
[ set plabel ""
set plabel-color white ]
end

to setup-omega
[ set plabel ""
set plabel-color white ]
end
```

There is only one version of this model, created about 1 year ago by Victor Iapascurta.

## Attached files

File Type Description Last updated