首页 > 其他分享 >习题2.8

习题2.8

时间:2024-10-22 13:23:26浏览次数:5  
标签:plt ret 2.8 rcParams np import 习题 1000

习题2.8代码
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'
from scipy.optimize import root
def fx(x):
ret = []
ret.append(4x[0] + x[1] - 1)
for i in range(1, 999):
ret.append(x[i-1] + 4
x[i] + x[i+1] - i - 1)
ret.append(x[998] + 4*x[999] - 1000)
return ret

root(fx, np.random.randn(1000))

A = 4*np.eye(1000) + np.eye(1000, k=-1) + np.eye(1000, k=1)
print(np.linalg.inv(A)@np.arange(1, 1001).reshape(1000, 1))

以下只展示部分解




标签:plt,ret,2.8,rcParams,np,import,习题,1000
From: https://www.cnblogs.com/DENWOSHUABAZONGSHI/p/18492450

相关文章

  • 习题2.7
    习题2.7代码importnumpyasnpimportpandasaspdimportsympyasspsp.init_printing(use_unicode=True)importmatplotlib.pyplotaspltplt.rcParams['font.sans-serif']=['TimesNewRoman+SimSun+WFMSansSC']plt.rcParams['mathtext......
  • 习题2.6
    习题2.6代码importnumpyasnpimportpandasaspdimportsympyasspsp.init_printing(use_unicode=True)importmatplotlib.pyplotaspltplt.rcParams['font.sans-serif']=['TimesNewRoman+SimSun+WFMSansSC']plt.rcParams['mathtext......
  • 习题2.4
    习题2.4代码importnumpyasnpimportpandasaspdimportsympyasspsp.init_printing(use_unicode=True)importmatplotlib.pyplotaspltplt.rcParams['font.sans-serif']=['TimesNewRoman+SimSun+WFMSansSC']plt.rcParams['mathtext......
  • 习题4.4
    习题4.4代码importcvxpyascpimportnumpyasnpimportpandasaspdimportsympyasspsp.init_printing(use_unicode=True)importmatplotlib.pyplotaspltplt.rcParams['font.sans-serif']=['TimesNewRoman+SimSun+WFMSansSC']plt.rcPa......
  • 习题3.2
    习题3.2代码importnumpyasnpimportpandasaspdimportsympyasspsp.init_printing(use_unicode=True)importmatplotlib.pyplotaspltplt.rcParams['font.sans-serif']=['TimesNewRoman+SimSun+WFMSansSC']plt.rcParams['mathtext......
  • 习题3.3
    习题3.3代码importnumpyasnpimportpandasaspdimportsympyasspsp.init_printing(use_unicode=True)importmatplotlib.pyplotaspltplt.rcParams['font.sans-serif']=['TimesNewRoman+SimSun+WFMSansSC']plt.rcParams['mathtext......
  • 习题2.13
    习题2.13代码importnumpyasnpimportpandasaspdimportsympyasspsp.init_printing(use_unicode=True)importmatplotlib.pyplotaspltplt.rcParams['font.sans-serif']=['TimesNewRoman+SimSun+WFMSansSC']plt.rcParams['mathtex......
  • 习题2.12
    习题2.12代码importnumpyasnpimportpandasaspdimportsympyasspsp.init_printing(use_unicode=True)importmatplotlib.pyplotaspltplt.rcParams['font.sans-serif']=['TimesNewRoman+SimSun+WFMSansSC']plt.rcParams['mathtex......
  • 习题4.3
    习题4.3代码importcvxpyascpimportnumpyasnpimportmatplotlib.pyplotaspltplt.rcParams['font.sans-serif']=['TimesNewRoman+SimSun+WFMSansSC']plt.rcParams['mathtext.fontset']='stix'TimesNewRoman+SimS......
  • 习题5.7
    习题5.7代码importcvxpyimportcvxpyascpimportnumpyasnpimportpandasaspdfromscipy.optimizeimportminimizeimportsympyasspsp.init_printing(use_unicode=True)importmatplotlib.pyplotaspltx=cp.Variable(3,integer=True)cumulative_output=c......