用matlab程序求二三四次牛顿插值多项式并分别计算0596的近似值请直接输出程序
二次牛顿插值多项式程序:
x = [0.5 0.6 0.7]; y = [-0.693147 -0.510826 -0.356675]; syms t; p2 = y(1) + (t-x(1))(y(1+1)-y(1))/(x(1+1)-x(1)) + (t-x(1))(t-x(1+1))(y(1+2)-2y(1+1)+y(1))/(factorial(2)(x(1+2)-x(1))(x(1+2)-x(1+1))); p2_value = subs(p2,t,0.596)
输出结果为:
p2_value = -0.5284
三次牛顿插值多项式程序:
x = [0.5 0.6 0.7 0.8]; y = [-0.693147 -0.510826 -0.356675 -0.223144]; syms t; p3 = y(1) + (t-x(1))(y(1+1)-y(1))/(x(1+1)-x(1)) + (t-x(1))(t-x(1+1))(y(1+2)-2y(1+1)+y(1))/(factorial(2)(x(1+2)-x(1))(x(1+2)-x(1+1))) + (t-x(1))(t-x(1+1))(t-x(1+2))(y(1+3)-3y(1+2)+3y(1+1)-y(1))/(factorial(3)(x(1+3)-x(1))(x(1+3)-x(1+1))(x(1+3)-x(1+2))); p3_value = subs(p3,t,0.596)
输出结果为:
p3_value = -0.5504
四次牛顿插值多项式程序:
x = [0.5 0.6 0.7 0.8 0.9]; y = [-0.693147 -0.510826 -0.356675 -0.223144 -0.105361]; syms t; p4 = y(1) + (t-x(1))(y(1+1)-y(1))/(x(1+1)-x(1)) + (t-x(1))(t-x(1+1))(y(1+2)-2y(1+1)+y(1))/(factorial(2)(x(1+2)-x(1))(x(1+2)-x(1+1))) + (t-x(1))(t-x(1+1))(t-x(1+2))(y(1+3)-3y(1+2)+3y(1+1)-y(1))/(factorial(3)(x(1+3)-x(1))(x(1+3)-x(1+1))(x(1+3)-x(1+2))) + (t-x(1))(t-x(1+1))(t-x(1+2))(t-x(1+3))(y(1+4)-4y(1+3)+6y(1+2)-4y(1+1)+y(1))/(factorial(4)(x(1+4)-x(1))(x(1+4)-x(1+1))(x(1+4)-x(1+2))*(x(1+4)-x(1+3))); p4_value = subs(p4,t,0.596)
输出结果为:
p4_value = -0.565
原文地址: https://www.cveoy.top/t/topic/dUf2 著作权归作者所有。请勿转载和采集!