<jupyter_start><jupyter_text>Introduction to dynamical systemsProfessor: <NAME>) Kudriashov<jupyter_code>%matplotlib widget
import math
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from scipy.integrate import solve_ivp
import ipywidgets as widgets<jupyter_output><empty_output><jupyter_text>$$\ddot x+w^2x=0$$<jupyter_code>fig, ax = plt.subplots(figsize=(6, 4))
ax.set_ylim([-5, 5])
ax.grid(True)

Y, X = np.mgrid[-5:5:100j, -5:5:100j]

@widgets.interact(w=(0.1, 2.0))
def oscillator(w):
    ax.clear()
    U = Y
    V = -w ** 2 * X
    ax.streamplot(X, Y, U, V)
fig, ax = plt.subplots(figsize=(6, 4))

Y, X = np.mgrid[-5:5:100j, -5:5:100j]

@widgets.interact(w=(-2.0, 2.0))
def oscillator2(w):
    ax.clear()
    ax.set_ylim([-5, 5])
    ax.set_xlim([-5, 5])
    U = Y
    V = -X + w * Y
    ax.streamplot(X, Y, U, V, start_points=[(2, 0)])<jupyter_output><empty_output><jupyter_text>$\ddot x=-x+\sin(\omega t)$<jupyter_code>fig = plt.figure(figsize=plt.figaspect(0.5))
ax1 = fig.add_subplot(1, 2, 1)
ax2 = fig.add_subplot(1, 2, 2, projection='3d')

@widgets.interact(w=(-0.5, 1.5, 0.05))
def oscillator3(w=0):
    ax1.clear()
    for pt in [(1, 0), (0, 1)]:
        ax2.clear()
        r = solve_ivp(lambda t, x: (x[1], -x[0]+math.sin(w * t)), (0, 200), pt, dense_output=True)
        T = np.linspace(0, 200, 1000)
        Y = r.sol(T)
        ax1.plot(T, Y[0])
        ax2.plot(T, Y[0], Y[1])
    ax1.set_ylim(-6, 6)<jupyter_output><empty_output><jupyter_text>$\dot x=-10x+10y$, $\dot y=28x-y-xz$, $\dot z=-(8/3)z+xy$<jupyter_code>fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d')

@widgets.interact(w=(-0.5, 1.5, 0.05))
def lorenz(w=0):
    ax.clear()
    for pt in [(0.01, 0, 0)]:
        r = solve_ivp(lambda t, x: (-10*x[0]+10*x[1], 28*x[0] - x[1] - x[0] * x[2], (-8/3)*x[2] + x[0]*x[1]), (0, 200), pt, dense_output=True)
        T = np.linspace(0, 30, 10000)
        Y = r.sol(T)
        ax.plot(Y[0], Y[1], Y[2])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2170889220069548, 'fraction_numerical': 0.07501241927471436, 'mean_word_length': 3.6192660550458715, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '229392', 'license': 'MIT', 'n_tokens_mistral': 1033, 'n_tokens_neox': 956, 'n_words': 181, 'path': 'Lecture1.ipynb', 'repo_name': 'urkud/mat332-notebooks', 'size': '2018'}