<jupyter_start><jupyter_text>1. LINEAR Difference equations    1.1. Motivation - easiest case      - malthusian growth (linear, 1-variable, 1st degree)<jupyter_code>import matplotlib.pyplot as PLT
import numpy as NP
import math as M



def full_plot(seq):
    x = seq
    PLT.subplots_adjust(wspace = 0.7, hspace=0.7)
    PLT.figure(1)
    PLT.subplot(221)
    PLT.title('A: (linear) value vs time')
    PLT.xlabel('time')
    PLT.ylabel('population/capital')
    PLT.plot(x, 'r.', x, 'r')
    
    PLT.subplot(222)
    PLT.title('B: (log) value vs time')

    PLT.xlabel('time')
    PLT.ylabel('population (log scale)')
    PLT.semilogy(x, 'r.')
    
    PLT.subplot(223)
    x_old = x[0:n_ticks-1]
    x_new = x[1:n_ticks]
    PLT.title('C: lag plot')
    PLT.xlabel('x old')
    PLT.ylabel('x new')
    PLT.plot(x_old, x_new, 'b.', x_old, x_old, 'c')

    PLT.subplot(224)
    PLT.xlabel('x old (log scale)')
    PLT.ylabel('x new (log scale)')
    PLT.title('D: lagplot (log)')
    PLT.loglog(x_old, x_new, 'b.', x_old, x_old, 'c')
    PLT.show()
    
n_ticks=15
x = [i for i in range(n_ticks)]
x[0]=0.2
alpha = 1.3 # 'reproductive rate' of flies = interest rate of capital
for t in range(n_ticks-1):
    x[t+1] = alpha * x[t]   
    
full_plot(x)<jupyter_output><empty_output><jupyter_text>1.2. Classification of problems         * differential/ difference      * linear/ non-linear      * static/dynamic [driven (?)]      * n-th degree      * vector/scalar     1.3. More examples: pendulum.      - pendulum (linear, 1-variable, 2nd degree)    1.4. Linear; vector case    MOTIVATION: Pendulum    STABILITY:    	- fixed point - attracting/repelling/neutral(?)/saddle	- cycle - ('ditto')     1.5. Closed form solution      - general solution (linear, 1-variable, n-th degree)     1.6. PARAMETER ESTIMATION      - AR to estimate parameters  2. NON-linear difference equations    2.1. Motivation: logistic parabola       - logistic parabola (pop. of flies - sir <NAME>)       - crash intro to chaos<jupyter_code>import matplotlib.pyplot as PLT
import numpy as NP

n_ticks=30
x = [i for i in range(n_ticks)]
x[0]=0.2
alpha = 3.5 # 'reproductive rate' of flies
for t in range(n_ticks-1):
    x[t+1] = alpha * x[t] * (1 - x[t])

full_plot(x)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14323490524460114, 'fraction_numerical': 0.026443367122080213, 'mean_word_length': 2.961605584642234, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '608735', 'license': 'Apache-2.0', 'n_tokens_mistral': 928, 'n_tokens_neox': 880, 'n_words': 220, 'path': 'DS_intro.ipynb', 'repo_name': 'cfaloutsos/NLDS', 'size': '2273'}