<jupyter_start><jupyter_text>Task 3<jupyter_code>from utilities import create_phase_portrait_derivative, plot_traj, plot_cusp_bifurcation
import numpy as np<jupyter_output><empty_output><jupyter_text>**Task3.1**Plot three phase diagrams of the following system:$$\dot x_1 = \alpha x_1 - x_2 - x_1(x_1^2 + x_2^2)$$$$\dot x_2 = x_1 + \alpha x_2 - x_2(x_1^2 + x_2^2)$$<jupyter_code>odes = ["alpha * x1 - x2 - x1 * (x1 ** 2 + x2 ** 2)", "x1 + alpha * x2 - x2 * (x1 ** 2 + x2 ** 2)"]
# showing the phase portrait of steady state behaviour
fig = create_phase_portrait_derivative(system=odes, alpha=-1, title_suffix="attracting steady state", fig_size=5)
# showing the phase portrait at bifurcation point
create_phase_portrait_derivative(system=odes, alpha=0, title_suffix="bifurcation point", fig_size=5)
# showing the phase portrait of limit cycle behaviour
create_phase_portrait_derivative(system=odes, alpha=1, title_suffix="attracting limit cycle", fig_size=5)<jupyter_output><empty_output><jupyter_text>**Task3.2**Numerically compute and visualize two orbits of the system forward in time, starting at thepoint (2; 0) and at (0:5; 0) for: $\alpha= 1$ $\newline$You can use Euler's method with a very small time step, or any numericalsolver, but you have to descibe how you obtain the results.<jupyter_code># plotting trajectory for first starting point
plot_traj(system=odes, start_pos=np.array([2, 0]), alpha=1, iter_num=1e4, fig_size=5)
# plotting trajectory for second starting point
plot_traj(system=odes, start_pos=np.array([0.5, 0]), alpha=1, iter_num=1e4, fig_size=5)<jupyter_output><empty_output><jupyter_text>**Task3.3**Visualize the bifurcation surface of the $\textit{cusp bifurcation}$ in a 3D plot,$$\dot x = \alpha_1 + \alpha_2 x - x^3$$<jupyter_code># plot the cusp bifurcation sampling alpha_2 and x n times
plot_cusp_bifurcation(alpha_two_limit=1.5, x_limit=1.5, n=400000)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12095933263816476, 'fraction_numerical': 0.040145985401459854, 'mean_word_length': 6.83265306122449, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '661108', 'license': 'MIT', 'n_tokens_mistral': 744, 'n_tokens_neox': 678, 'n_words': 187, 'path': 'EX3/task3.ipynb', 'repo_name': 'AlexPasqua/MLCMS-exercises', 'size': '1918'}