logistic2.py

Created by vnap0v

Created on May 01, 2025

505 Bytes

Function logistic_map() draws the bifurcation diagram of the logistic map on the screen. Uses libraries math and kandinsky. Can be used with 2 parameters logistic_map(astart, aend). Tested on the calculator using software version 23.2.6.


from math import *
import kandinsky
# bifurcation diagram 
# of logistic map
def logistic_map(astart=3.5,aend=4):
  aspan=aend-astart
  stap=4
  for x in range(320):
    a=astart+aspan*x/319
    l=0.5
    y=[0]*240
    for i in range(1500):
      l=a*l*(1-l)
      oldy=y[int(l*239)]
      y[int(l*239)]=stap+oldy  
    for r in range(240):
      if y[239-r]>255:
        y[239-r]=255
      co=kandinsky.color(y[239-r],y[239-r],y[239-r])
      kandinsky.set_pixel(x,r,co)

logistic_map()

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.