
Advanced Engineering Mathematics
10th Edition
ISBN: 9780470458365
Author: Erwin Kreyszig
Publisher: Wiley, John & Sons, Incorporated
expand_more
expand_more
format_list_bulleted
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
![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()](https://content.bartleby.com/qna-images/question/6d0ee2cb-cfe2-4eb9-a097-d38324436758/31739f29-dcbc-41ae-a40b-3dc84de4a1fe/v2ellz9_thumbnail.jpeg)
Transcribed Image Text: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()
SAVE
AI-Generated Solution
info
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
to generate a solution
Click the button to generate
a solution
a solution
Knowledge Booster
Similar questions
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Advanced Engineering MathematicsAdvanced MathISBN:9780470458365Author:Erwin KreyszigPublisher:Wiley, John & Sons, IncorporatedNumerical Methods for EngineersAdvanced MathISBN:9780073397924Author:Steven C. Chapra Dr., Raymond P. CanalePublisher:McGraw-Hill EducationIntroductory Mathematics for Engineering Applicat...Advanced MathISBN:9781118141809Author:Nathan KlingbeilPublisher:WILEY
- Mathematics For Machine TechnologyAdvanced MathISBN:9781337798310Author:Peterson, John.Publisher:Cengage Learning,

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,

