1 # -*- coding: utf-8 -*- 2 """ 3 Created on Wed Sep 6 19:35:03 2023 4 5 @author: shixi 6 """ 7 # 2.2(1) 8 x0,x1,x2 = 0.46,0.47,0.48 9 y0,y1,y2 = 0.4846555,0.4937452,0.5027498 10 11 def p2(x): 12 return y0*(x-x1)*(x-x2)/((x0-x1)*(x0-x2)) \ 13 + y1*(x-x0)*(x-x2)/((x1-x0)*(x1-x2)) \ 14 + y2*(x-x0)*(x-x1)/((x2-x0)*(x2-x1)) 15 16 print(p2(0.472)) 17 18 # 2.2(2) 19 x0,x1,x2 = 0.4937452,0.5027498,0.5116683 20 y0,y1,y2 = 0.47,0.48,0.49 21 22 def p2(x): 23 return y0*(x-x1)*(x-x2)/((x0-x1)*(x0-x2)) \ 24 + y1*(x-x0)*(x-x2)/((x1-x0)*(x1-x2)) \ 25 + y2*(x-x0)*(x-x1)/((x2-x0)*(x2-x1)) 26 27 print(p2(0.5))
标签:y2,数值,y1,y0,x2,2.2,习题,x1,x0 From: https://www.cnblogs.com/wangshixi12/p/17683412.html