8.4

-- coding: utf-8 --

"""
Created on Tue Nov 12 13:41:18 2024

@author: 朱尧
"""

import numpy as np
import pandas as pd
import sympy as sp
sp.init_printing(use_latex=True)
from scipy.integrate import odeint
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['Times New Roman + SimSun + WFM Sans SC']
plt.rcParams['mathtext.fontset']='stix'
plt.rcParams['axes.unicode_minus']=False
plt.rcParams['figure.dpi'] = 200
plt.rcParams['xtick.direction']='in'
plt.rcParams['ytick.direction']='in'
def rhs(f, t):
x, y = f
return [
-x3 - y,
x - y
3,
]
tt = np.linspace(0, 30, 301)
ns = odeint(rhs, [1, 0.5], tt)
xx, yy = ns[:,0], ns[:,1]

fig = plt.figure(figsize=(6,3))
ax = fig.add_subplot(121)
ax.plot(tt, xx, label='$x(t)$')
ax.plot(tt, yy, label='$y(t)$')
ax.legend()

ax1 = fig.add_subplot(122)
ax1.plot(xx, yy)

fig.show()

posted @ 2024-11-12 14:07  世梦  阅读(15)  评论(0)    收藏  举报