• 计算方法 | NEWTON 插值


    先引入差商的概念,类似一种迭代计算?

    丢代码:

     1 import numpy as np
     2 data = [(0.4,0.41075),(0.55,0.57815),(0.65,0.69675),(0.8,0.88811),(0.9,1.02652)]
     3 
     4 count = len(data)
     5 N = [[0 for j in range(count-i)] for i in range(count)]
     6 for i in range(count):
     7     N[0][i] = data[i][1]
     8 print(N)
     9 # 求差商表(关键点)
    10 for i in range(1, len(N)):
    11     for j in range(len(N[i])):
    12         N[i][j] = (N[i-1][j+1] - N[i-1][j]) / (data[j+i][0] - data[j][0])
    13 print(N)
    14 
    15 # 差值x
    16 x = 0.596
    17 _sum = 0
    18 for i in range(count):
    19     _mult = N[i][0]
    20     print(N[i][0],end="")
    21     for j in range(i):
    22         _mult *= x-data[j][0]
    23         print("(x-{})".format(data[j][0]),end= "")
    24     print("+")
    25     _sum += _mult
    26 print(_sum)

    over。

  • 相关阅读:
    mac下配置openCV
    K最短路 A*算法
    KMP算法
    北航复试机试题
    1385重建二叉树
    二维数组中的查找
    简单的单向链表
    Getting Started with WebRTC [note]
    我的c漏洞
    PeerConnection
  • 原文地址:https://www.cnblogs.com/Mz1-rc/p/13899262.html
Copyright © 2020-2023  润新知