m0_59759913 2021-09-08 11:49 采纳率: 72.2%
浏览 44
已结题

linear algebra and python

Suppose K is the 9 by 9 second difference matrix (2's on the diagonal, -1's on the diagonal above and also below). Solve the equation Kx = b = (10, ..., 10). If you graph x1, ..., x9 above the points 1, ..., 9 on the x axis, I think the nine points fall on a parabola.

怎么用python画这个图?

这是答案,用的是matlab:

img

img

  • 写回答

3条回答 默认 最新

  • Pliosauroidea 2021-09-08 12:36
    关注

    笑死,我的线代全还给老师了
    直接进行一个恶补

    import numpy as np
    from matplotlib import pyplot as plt
    
    K = np.eye(9) * 2
    np.fill_diagonal(K[:-1, 1:], -1)
    np.fill_diagonal(K[1:, :-1], -1)
    print(K)
    
    # print(K1)
    B = np.ones((9, 1)) * 10
    print(B)
    X = np.linalg.solve(K, B)
    print(X)
    # X = B / K
    # print(X)
    plt.plot(range(X.shape[0]), X)
    plt.show()
    

    img

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 9月16日
  • 已采纳回答 9月8日
  • 修改了问题 9月8日
  • 创建了问题 9月8日

悬赏问题

  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。
  • ¥20 CST怎么把天线放在座椅环境中并仿真
  • ¥15 任务A:大数据平台搭建(容器环境)怎么做呢?
  • ¥15 r语言神经网络自变量重要性分析
  • ¥15 基于双目测规则物体尺寸
  • ¥15 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型