import numpy as np import matplotlib. pyplot as plt from scipy. integrate import odeint # Define the system of differential equations def system(y, t): [z,p] = y dzdt= 2 * z - z* *2- z*p dpdt = p**2 p * (z**2) return [dzdt, dpdt] # Function to calculate the Jacobian matrix at an equilibrium point def jacobian_matrix (point): z, p = point return np.array ( [ [2 - 2+ z-p, -z], [-2 pz, 2 p - z**2]]) # Equilibrium points equilibrium_points = [(0, 0), (1, 1), (2, 0), (-2, 4)] # Set up the plot fig, axs plt.subplots (2, 2, figsize=(10, 8)) fig.suptitle('Phase Portraits for Linearized Solutions') # Plot linearized solutions at each equilibrium point for i, point in enumerate(equilibrium_points): # Calculate the Jacobian matrix at the equilibrium point A = jacobian_matrix (point) # Eigenvalues and eigenvectors eigenvalues, eigenvectors = np. linalg.eig (A) # Initial conditions for the linearized system ye = np.concatenate ([point, eigenvectors[:, 0]]) # Time points t = np. linspace(0, 5, 100) # Solve the linearized system linearized_solution = odeint (system, ye, t) #Plot the phase portrait axs[i // 2, 1 % 2].plot(linearized_solution[:, 0], linearized_solution[:, 1]) axs [i // 2, 1 % 2].set_title(f'Equilibrium Point: {point}') #Set common labels for ax in axs.flat: ax.set (xlabel='z', ylabel='p') # Adjust layout plt.tight_layout(rect= [0, 0.03, 1, 0.95]) # Show the plot plt.show()
import numpy as np import matplotlib. pyplot as plt from scipy. integrate import odeint # Define the system of differential equations def system(y, t): [z,p] = y dzdt= 2 * z - z* *2- z*p dpdt = p**2 p * (z**2) return [dzdt, dpdt] # Function to calculate the Jacobian matrix at an equilibrium point def jacobian_matrix (point): z, p = point return np.array ( [ [2 - 2+ z-p, -z], [-2 pz, 2 p - z**2]]) # Equilibrium points equilibrium_points = [(0, 0), (1, 1), (2, 0), (-2, 4)] # Set up the plot fig, axs plt.subplots (2, 2, figsize=(10, 8)) fig.suptitle('Phase Portraits for Linearized Solutions') # Plot linearized solutions at each equilibrium point for i, point in enumerate(equilibrium_points): # Calculate the Jacobian matrix at the equilibrium point A = jacobian_matrix (point) # Eigenvalues and eigenvectors eigenvalues, eigenvectors = np. linalg.eig (A) # Initial conditions for the linearized system ye = np.concatenate ([point, eigenvectors[:, 0]]) # Time points t = np. linspace(0, 5, 100) # Solve the linearized system linearized_solution = odeint (system, ye, t) #Plot the phase portrait axs[i // 2, 1 % 2].plot(linearized_solution[:, 0], linearized_solution[:, 1]) axs [i // 2, 1 % 2].set_title(f'Equilibrium Point: {point}') #Set common labels for ax in axs.flat: ax.set (xlabel='z', ylabel='p') # Adjust layout plt.tight_layout(rect= [0, 0.03, 1, 0.95]) # Show the plot plt.show()
Advanced Engineering Mathematics
10th Edition
ISBN:9780470458365
Author:Erwin Kreyszig
Publisher:Erwin Kreyszig
Chapter2: Second-order Linear Odes
Section: Chapter Questions
Problem 1RQ
Related questions
Question
what is wrong with the python code? Trying to plot phase portraits for the linearized systems for each equilibrium point of a non-linear system of
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
Unlock instant AI solutions
Tap the button
to generate a solution
Recommended textbooks for you
Advanced Engineering Mathematics
Advanced Math
ISBN:
9780470458365
Author:
Erwin Kreyszig
Publisher:
Wiley, John & Sons, Incorporated
Numerical Methods for Engineers
Advanced Math
ISBN:
9780073397924
Author:
Steven C. Chapra Dr., Raymond P. Canale
Publisher:
McGraw-Hill Education
Introductory Mathematics for Engineering Applicat…
Advanced Math
ISBN:
9781118141809
Author:
Nathan Klingbeil
Publisher:
WILEY
Advanced Engineering Mathematics
Advanced Math
ISBN:
9780470458365
Author:
Erwin Kreyszig
Publisher:
Wiley, John & Sons, Incorporated
Numerical Methods for Engineers
Advanced Math
ISBN:
9780073397924
Author:
Steven C. Chapra Dr., Raymond P. Canale
Publisher:
McGraw-Hill Education
Introductory Mathematics for Engineering Applicat…
Advanced Math
ISBN:
9781118141809
Author:
Nathan Klingbeil
Publisher:
WILEY
Mathematics For Machine Technology
Advanced Math
ISBN:
9781337798310
Author:
Peterson, John.
Publisher:
Cengage Learning,