This code is made to find the Bifurcation Diagram and Lyapunov Exponent of an arbitrary function. The examples made below are done using the Logistic Map, but the function can be changed in the script directly for any other function, following the structure set in the type-hinting.
The bifurcation diagrams are computed probabilistically in a sense, as the last set of points in the iteration process are considered as the critical points for each value of r. There is no direct computation of critical points, so the error could begin to increase as more points appear in the system.
The Lyapunov exponent is calculated using the derivative of the function given as an input, using the equation described in this article . The points above the red line are the ones we associate with chaotic behavior, as the Lyapunov exponent can be thought of as a measure of predictability.
Note that the values of r for which the Lyapunov Exponent is negative are the same values for which the bifurcation diagram has patches of fewer critical points.