数值计算方法三次样条插值法三种边界条件求插值函数并画出图像的python代码
数值计算方法三次样条插值法求插值函数并画出图像的python代码 第一类插值条件 #三次样条插值法 import matplotlib . pyplot as plt import numpy as np from sympy import * #第一类插值条件函数 def one ( x , y , a , b , n ) : h = np . zeros ( n ) u = np . zeros ( n - 1 ) r = np . zeros ( n - 1 ) g = np . zeros ( n + 1 ) A = np . zeros ( shape = ( n + 1 , n + 1 ) ) q = np . zeros ( n ) w = np . zeros ( n ) e = np . zeros ( n ) t = np . zeros ( n ) #计算和,u,r,g for i in range ( 0 , n ) : h [ i ] = x [ i + 1 ] - x [ i ] print ( "h=" , h ) for i in range ( 0 , n - 1 ) : u [ i ] = h [ i ] / ( h [ i ] + h [ i + 1 ] ) print ( "u=" , u ) for i in range ( 0 , n -