例1、 已知函数表
x -1 1 2 f(x) -3 0 4 求f(x)的Lagrange二次插值多项式和Newton二次插值多项式。 解:
(1) 由题可知 xk -1 1 2 yk-3 0 4
插值基函数分别为
l?x0(x)??x?x1??x2??x??x?1??x?2??1?2??16?x?1??x?2?
0?x1??x0?x2???1?1??l?1(x)??x?x0??x?x2?x??x?1??x?2?2???1?x?1??x?2?1?x0??x1?x2??1?1??1?2
l?x?x2(x)?0??x?x1??x?1??x?1?x?x???1?x?1??x?1?
20??x2?x1??2?1??2?1?3故所求二次拉格朗日插值多项式为
2L2(x)??yklk?x?k?0??3?16?x?1??x?2??0?????1?12?x?1??x?2????4?3?x?1??x?1?
??142?x?1??x?2??3?x?1??x?1??56x2?372x?3
(2)一阶均差、二阶均差分别为
1
f?x0,x1??f?x1,x2??f?x0??f?x1?x0?x1f?x1??f?x2?x1?x2???3?03??1?120?4?41?2
3f?x0,x1??f?x1,x2?2?45f?x0,x1,x2????x0?x2?1?26均差表为 xk -1 -3 1 2 0 4 3/2 4 5/6 f(xk) 一阶 二阶
故所求Newton二次插值多项式为
P2?x??f?x0??f?x0,x1??x?x0??f?x0,x1,x2??x?x0??x?x1?35?x?1???x?1??x?1?26537?x2?x?623??3?
例2、 设f(x)?x
解:
2?3x?2,x?[0,1],试求f(x)在[0, 1]上关于?(x)?1,??span?1,x?的最佳平方逼近多项式。
若??span?1,x?,则?0(x)?1,?1(x)?x,且?(x)?1,这样,有
??0,?0???1dx?1,011??1,?1???x2dx?011311??0,?1????1,?0???xdx?,20?f,?0????x2?3x?2?dx?023 6?f,?1???x?x2?3x?2?dx?0194所以,法方程为
1?1??23??23??12??a0???6? 2??a0??6?,经过消元得???????????9?a11???0??a1??1??1???????12??3??3????4??11再回代解该方程,得到a1?4,a0?
6??1??1??22
*故,所求最佳平方逼近多项式为S1(x)?x11?4x 6例3、 设f(x)?e,x?[0,1],试求f(x)在[0, 1]上关于?(x)?1,??span?1,x?的最佳
平方逼近多项式。 解:
若??span?1,x?,则?0(x)?1,?1(x)?x,这样,有
??0,?0?1??1dx?10?1?1,?1???x2dx?103??1?,??101??1,?0???xdx?
02?1f,?0???exdx?1.71830?1f,?1???xexdx?10所以,法方程为
??11??2??11??a0??????1.7183??1 ??2??a1????3?解法方程,得到a0?0.8732,a1?1.6902, 故,所求最佳平方逼近多项式为
S1*(x)?0.8732?1.6902x
例4、 用n?4的复合梯形和复合辛普森公式计算积分?91xdx。
解:
(1)用n?4的复合梯形公式
由于h?2,f?x??x,xk?1?2k?k?1,2,3?,所以,有
?91xdx?T4?h32[f?1??2?f?xk??f?9?]k?1
?22[1?2??3?5?7??9]?17.2277
3