3.2

2023310143015發表於2024-10-28

點選檢視程式碼
import numpy as np
import pandas as pd
import sympy as sp
sp.init_printing(use_unicode=True)
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['Times New Roman + SimSun + WFM Sans SC']
plt.rcParams['mathtext.fontset']='cm'
# Times New Roman + SimSun + WFM Sans SC
# simsum宋體, times new roman -*, simhei黑體, kaiti楷體,
# dengxian等線, fangsong仿宋, Microsoft Yahei微軟雅黑
plt.rcParams['axes.unicode_minus']=False
plt.rcParams['figure.dpi'] = 200
# plt.rcParams['figure.figsize'] = [4, 3]
# plt.rcParams['font.size'] = 12
plt.rcParams['xtick.direction'] = 'in'
plt.rcParams['ytick.direction'] = 'in'
x = sp.Function('x')
k = sp.var('k')
eq = x(k+2) - x(k+1) - 2*x(k)
s = sp.rsolve(eq, x(k), {x(0):-2, x(1):-2})
print(s)

相關文章