当前位置:文档之家› 西交大计算方法上机报告

西交大计算方法上机报告

计算方法(B)实验报告姓名:学号:学院:专业:实验一 三对角方程组Tx f =的求解一、 实验目的掌握三对角方程组Tx f =求解的方法。

二、 实验内容求三对角方程组Tx f =的解,其中:4 -1 -1 4 -1 -1 4 1 -1 4T ⎡⎤⎢⎥⎢⎥⎢⎥=⎢⎥⎢⎥⎢⎥⎣⎦ , 3223f ⎛⎫ ⎪ ⎪ ⎪= ⎪ ⎪ ⎪⎝⎭三、 算法组织设系数矩阵为三对角矩阵11222333111b c a b c a b c a b c b n n n n T ---⎡⎤⎢⎥⎢⎥⎢⎥=⎢⎥⎢⎥⎢⎥⎢⎥⎢⎥⎣⎦则方程组Tx f =称为三对角方程组。

设矩阵T 非奇异,T 可分解为T=LU ,其中L 为下三角矩阵,U 为单位上三角矩阵,记11212313111111,11n n n n n r l r l r L U l r l μμμμμ---⎛⎫⎛⎫⎪ ⎪ ⎪ ⎪ ⎪ ⎪==⎪⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎝⎭⎝⎭可先依次求出,L U 中的元素后,令Ux y =,先求解下三角方程组Ly f =得出y ,再求解上三角方程组Ux y =。

追赶法的算法组织如下:1.输入三对角矩阵T 和右端向量f ;2.将Tx f =压缩为四个一维数组{}{}{}{}i i i i a b c d 、、、,{}{}{}i i i a b c 、、是T 的三对角线性方程组的三个对角,{}i d 是右端向量。

将分解矩阵压缩为三个一维数组{}{}{}i i i l r μ、、。

3.对T 做Crout 分解(也可以用Doolittle 分解)导出追赶法的计算步骤如下:1111,b r c μ==for 2i n =111, ,,i i i i i i i i i i i i i l a b a r r c y d l y μμ---==-==-end4.回代求解x/n n n x y μ=for 11i n =-1()/i i i i i x y c x μ+=-end5. 停止,输出结果。

四、 MATLAB 程序 MATLAB 程序见附件1. 五、 结果及分析 实验结果为:(1.0000 1.00001.0000 1.0000)T x =实验二 Jacobi 迭代和Gauss-Seidel 迭代解线性方程组一、 实验目的掌握Jacobi 迭代和Gauss-Seidel 迭代解线性方程组的方法。

二、 实验内容用Jacobi 迭代和Gauss-Seidel 迭代解电路电流方程组,使各部分电流误差均小于310-。

212132343452328103831001025150154503050i i i i i i i i i i i i -=⎧⎪-+-=⎪⎪-+-=⎨⎪-+=⎪-+=⎪⎩ 三、 算法组织形如Ax b =的方程组,用Jacobi 迭代求解x ,算法组织如下:1. 将系数矩阵A 分解成对角元D 、下三角部分元E -和上三角部分元F -,于是A D E F =--.2. 由11()()()Ax b D E F x b Dx E F x b x D E F x D b --=⇒--=⇒=++⇒=++。

3. 从而构成形如(1)()k k x Gx d +=+迭代格式:(1)1()1()k k x D E F x D b +--=++其中11()G D E F d D b--⎧=+⎨=⎩ 4. 选取初始向量(0)x 进行迭代计算。

5. 当迭代后的解满足题中的约束条件(1)()1max k k i i i nx x ε+≤≤-<时迭代停止。

形如Ax b =的方程组,用Gauss —Seidel 迭代求解x ,算法组织如下: 1. 将系数矩阵A 分解成对角元D 、下三角部分元E -和上三角部分元F -,于是A D E F =--.2. 由11()()()()Ax b D E F x b D E x Fx b x D E Fx D E b --=⇒--=⇒-=+⇒=-+-。

3. 从而构成形如(1)()k k x Gx d +=+迭代格式:(1)1()1()()k k x D E Fx D E b +--=-+- 其中11()()G D E Fd D E b--⎧=-⎨=-⎩ 4. 选取初始向量(0)x 进行迭代计算。

5. 当迭代后的解满足题中的约束条件(1)()1max k k i i i nx x ε+≤≤-<时迭代停止。

四、 MATLAB 程序MATLAB 程序见附件2,其中1为Jacobi 迭代,2为Gauss —Seidel 迭代。

五、 结果及分析 Jacobi 迭代结果:方程组的解为(0.36070.03350.01630.00540.0055)T x = 迭代次数8i =Gauss —Seidel 迭代结果:方程组的解为(0.36070.03350.01660.00550.0056)T x = 迭代次数4i =由以上结果可知,达到相同的计算精度,Gauss —Seidel 迭代比Jacobi 迭代的速度快,Gauss —Seidel 迭代比Jacobi 迭代次数少。

实验三 多项式插值及误差计算一、实验目的掌握多项式插值的原理和基本方法。

二、实验内容已知21()(11)125f x x x=-≤≤+,对5,10,20n = a. 计算函数()f x 在点21,(0,1,2,,)i x i i n n=-+=处的值()i f x ;b. 求插值数据点(){},(0,1,2,,)i i x y i n =的Newton 插值多项式()n N x 和三次样条插值多项式()n S x ; c. 对5,20n =,计算21,(110,9099)100k x k k =-+=和相应的函数值(),(),()k n k n k k y f x N x S x =;d. 计算()()max n n k k kE N y N x =-,()()max n n k k kE S y S x =-,解释所得到结果。

三、 算法组织(一)本题第一问是简单的用matlab 程序可以计算,算法很简单。

(二) 本题在算法上第二问中的Newton 插值多项式)(x N n 和三次样条插值多项式()n S x 。

计算两种插值多项式的算法如下: 1. 求Newton 插值多项式)(x N n ,算法组织如下:Newton 插值多项式的表达式如下:010011()()()()()n n n N x c c x x c x x x x x x -=+-+⋅⋅⋅+--⋅⋅⋅-其中每一项的系数c i 的表达式如下:12011010(,,,)(,,,)(,,,)i i i i i f x x x f x x x c f x x x x x -⋅⋅⋅-⋅⋅⋅=⋅⋅⋅=-根据上述公式,为了得到系数需计算:1) 一阶差商01[],[],,[]n f x f x f x ⋅⋅⋅ 2) 二阶差商01121[,],[,],[,]n n f x x f x x f x x -⋅⋅⋅ … … … …3) n 阶差商01111[,,,],[,,,]n n n f x x x f x x x --⋅⋅⋅⋅⋅⋅ 4) n+1阶差商011[,,,,]n n f x x x x -⋅⋅⋅2. 求三次样条插值多项式,算法组织如下:所谓三次样条插值多项式()n S x 是一种对区间进行分段的分段函数,然后在每一段上进行分析,即它在节点i x 011()n n a x x x x b -=<<⋅⋅⋅<<=分成的每个小区间1[,]i i x x -上是3次多项式,其在此区间上的表达式如下:22331111111()[()()]()()666[,]1,2,,.i i i i i i i i i i i i i i ii i h x x h x x S x x x M x x M y M y M h h h x x x i n --------=-+-+-+-∈=⋅⋅⋅,, 因此,只要确定了i M 的值,就确定了整个表达式,i M 的计算方法如下: 令:11111111116()6(,,)i i i i i i i i i i i i i ii i i i i i i h h h h h h y y y y d f x x x h h h h μλμ++++--+++⎧===-⎪++⎪⎨--⎪=-=⎪+⎩, 则i M 满足如下n-1个方程:1121,2,,1i i i i i i M M M d i n μλ-+++==⋅⋅⋅-,方程中有n+1个未知量,则令0M 和n M 分别为零,则由上面的方程组可得到(11)i M i n ≤≤-的值,可得到整个区间上的三次样条插值多项式()n S x 。

(三) 第三问和第四问的算法与第二问的算法类似,不再赘述。

四、 MATLAB 程序 MATLAB 程序见附件3。

五、 结果及分析 第一问当n=5时,各节点及f(x)值为: x(0)=-1,y(0)=3.846154e-02x(2)=-2.000000e-01,y(2)=5.000000e-01 x(3)=2.000000e-01,y(3)=5.000000e-01 x(4)=6.000000e-01,y(4)=1.000000e-01 x(5)=1,y(5)=3.846154e-02当n=10时,各节点及f(x)值为:x(0)=-1,y(0)=3.846154e-02x(1)=-8.000000e-01,y(1)=5.882353e-02 x(2)=-6.000000e-01,y(2)=1.000000e-01 x(3)=-4.000000e-01,y(3)=2.000000e-01 x(4)=-2.000000e-01,y(4)=5.000000e-01 x(5)=0,y(5)=1x(6)=2.000000e-01,y(6)=5.000000e-01 x(7)=4.000000e-01,y(7)=2.000000e-01 x(8)=6.000000e-01,y(8)=1.000000e-01 x(9)=8.000000e-01,y(9)=5.882353e-02 x(10)=1,y(10)=3.846154e-02当n=20时,各节点及f(x)值为:x(0)=-1,y(0)=3.846154e-02x(1)=-9.000000e-01,y(1)=4.705882e-02 x(2)=-8.000000e-01,y(2)=5.882353e-02 x(3)=-7.000000e-01,y(3)=7.547170e-02 x(4)=-6.000000e-01,y(4)=1.000000e-01 x(5)=-5.000000e-01,y(5)=1.379310e-01 x(6)=-4.000000e-01,y(6)=2.000000e-01 x(7)=-3.000000e-01,y(7)=3.076923e-01x(9)=-1.000000e-01,y(9)=8.000000e-01 x(10)=0,y(10)=1x(11)=1.000000e-01,y(11)=8.000000e-01 x(12)=2.000000e-01,y(12)=5.000000e-01 x(13)=3.000000e-01,y(13)=3.076923e-01 x(14)=4.000000e-01,y(14)=2.000000e-01 x(15)=5.000000e-01,y(15)=1.379310e-01 x(16)=6.000000e-01,y(16)=1.000000e-01 x(17)=7.000000e-01,y(17)=7.547170e-02 x(18)=8.000000e-01,y(18)=5.882353e-02 x(19)=9.000000e-01,y(19)=4.705882e-02 x(20)=1,y(20)=3.846154e-02第二问牛顿插值算法当n=5时Newton插值多项式的系数分别为:c[0]=3.846154e-02c[1]=1.538462e-01c[2]=1.057692e+00c[3]=-1.923077e+00c[4]=1.201923e+00c[5]=-5.551115e-16当n=10时Newton插值多项式的系数分别为:c[0]=3.846154e-02c[1]=1.018100e-01c[2]=2.601810e-01c[3]=7.918552e-01c[4]=2.686652e+00c[5]=-6.363122e+00c[6]=-1.767534e+01c[7]=8.484163e+01c[8]=-1.679157e+02c[9]=2.209417e+02c[10]=-2.209417e+02当n=20时Newton插值多项式的系数分别为:c[0]=3.846154e-02c[1]=8.597285e-02c[2]=1.583710e-01c[3]=2.860070e-01c[4]=5.335952e-01c[5]=1.037751e+00c[6]=2.001902e+00c[7]=2.796775e+00c[8]=-7.543931e+00c[9]=-1.011991e+02c[10]=-6.439941e+01c[11]=2.152780e+03c[12]=-7.267934e+03c[13]=1.139374e+04c[14]=-3.538429e+03c[15]=-2.830744e+04c[16]=8.669152e+04c[17]=-1.592293e+05c[18]=2.237536e+05c[19]=-2.601786e+05c[20]=2.601786e+05三次样条插值算法当n=5时,取边界条件为自然样条的三次样条插值多项式的系数分别为:m =4.1296-3.8259-3.82594.1296当n=10时,取边界条件为自然样条的三次样条插值多项式的系数分别为:m =0.41011.48202.485618.575518.57552.48561.48200.4101当n=20时,取边界条件为自然样条的三次样条插值多项式的系数分别为:m =0.36150.45430.75141.26812.21774.34387.781015.3016-4.3719-57.8141-4.371915.30167.78104.34381.26810.75140.45430.3615第三问当n=5时,给定点xi的f(xi),N(xi),S(xi),分别为:x(1)=-9.800000e-01, f=3.998401e-02, N=1.369250e-02, S=3.604615e-02x(2)=-9.600000e-01, f=4.159734e-02, N=-6.920000e-03, S=3.371336e-02x(3)=-9.400000e-01, f=4.330879e-02, N=-2.359981e-02, S=3.154575e-02x(4)=-9.200000e-01, f=4.512635e-02, N=-3.656615e-02, S=2.962591e-02x(5)=-9.000000e-01, f=4.705882e-02, N=-4.603365e-02, S=2.803644e-02x(6)=-8.800000e-01, f=4.911591e-02, N=-5.221231e-02, S=2.685992e-02x(7)=-8.600000e-01, f=5.130836e-02, N=-5.530750e-02, S=2.617895e-02x(8)=-8.400000e-01, f=5.364807e-02, N=-5.552000e-02, S=2.607611e-02x(9)=-8.200000e-01, f=5.614823e-02, N=-5.304596e-02, S=2.663401e-02x(10)=-8.000000e-01, f=5.882353e-02, N=-4.807692e-02, S=2.793522e-02x(11)=-7.800000e-01, f=6.169031e-02, N=-4.079981e-02, S=3.006235e-02x(12)=-7.600000e-01, f=6.476684e-02, N=-3.139692e-02, S=3.309798e-02x(13)=-7.400000e-01, f=6.807352e-02, N=-2.004596e-02, S=3.712470e-02x(14)=-7.200000e-01, f=7.163324e-02, N=-6.920000e-03, S=4.222510e-02x(15)=-7.000000e-01, f=7.547170e-02, N=7.812500e-03, S=4.848178e-02x(16)=-6.800000e-01, f=7.961783e-02, N=2.398769e-02, S=5.597733e-02x(17)=-6.600000e-01, f=8.410429e-02, N=4.144635e-02, S=6.479433e-02x(18)=-6.400000e-01, f=8.896797e-02, N=6.003385e-02, S=7.501538e-02x(19)=-6.200000e-01, f=9.425071e-02, N=7.960019e-02, S=8.672308e-02x(20)=-6.000000e-01, f=1.000000e-01, N=1.000000e-01, S=1.000000e-01x(21)=-5.800000e-01, f=1.062699e-01, N=1.210925e-01, S=1.148885e-01x(22)=-5.600000e-01, f=1.131222e-01, N=1.427415e-01, S=1.312696e-01x(23)=-5.400000e-01, f=1.206273e-01, N=1.648156e-01, S=1.489844e-01x(24)=-5.200000e-01, f=1.288660e-01, N=1.871877e-01, S=1.678737e-01x(25)=-5.000000e-01, f=1.379310e-01, N=2.097356e-01, S=1.877783e-01x(26)=-4.800000e-01, f=1.479290e-01, N=2.323415e-01, S=2.085393e-01x(27)=-4.600000e-01, f=1.589825e-01, N=2.548925e-01, S=2.299974e-01x(28)=-4.400000e-01, f=1.712329e-01, N=2.772800e-01, S=2.519935e-01x(29)=-4.200000e-01, f=1.848429e-01, N=2.994002e-01, S=2.743686e-01x(30)=-4.000000e-01, f=2.000000e-01, N=3.211538e-01, S=2.969636e-01x(31)=-3.800000e-01, f=2.169197e-01, N=3.424463e-01, S=3.196192e-01x(32)=-3.600000e-01, f=2.358491e-01, N=3.631877e-01, S=3.421765e-01x(33)=-3.400000e-01, f=2.570694e-01, N=3.832925e-01, S=3.644763e-01x(34)=-3.200000e-01, f=2.808989e-01, N=4.026800e-01, S=3.863595e-01x(35)=-3.000000e-01, f=3.076923e-01, N=4.212740e-01, S=4.076670e-01x(36)=-2.800000e-01, f=3.378378e-01, N=4.390031e-01, S=4.282397e-01x(37)=-2.600000e-01, f=3.717472e-01, N=4.558002e-01, S=4.479184e-01x(38)=-2.400000e-01, f=4.098361e-01, N=4.716031e-01, S=4.665441e-01x(39)=-2.200000e-01, f=4.524887e-01, N=4.863540e-01, S=4.839577e-01x(40)=-2.000000e-01, f=5.000000e-01, N=5.000000e-01, S=5.000000e-01x(41)=-1.800000e-01, f=5.524862e-01, N=5.124925e-01, S=5.145385e-01x(42)=-1.600000e-01, f=6.097561e-01, N=5.237877e-01, S=5.275466e-01x(43)=-1.400000e-01, f=6.711409e-01, N=5.338463e-01, S=5.390243e-01x(44)=-1.200000e-01, f=7.352941e-01, N=5.426338e-01, S=5.489717e-01x(45)=-1.000000e-01, f=8.000000e-01, N=5.501202e-01, S=5.573887e-01x(46)=-8.000000e-02, f=8.620690e-01, N=5.562800e-01, S=5.642753e-01x(47)=-6.000000e-02, f=9.174312e-01, N=5.610925e-01, S=5.696316e-01x(48)=-4.000000e-02, f=9.615385e-01, N=5.645415e-01, S=5.734575e-01x(49)=-2.000000e-02, f=9.900990e-01, N=5.666156e-01, S=5.757530e-01x(50)=0, f=1, N=5.673077e-01, S=5.765182e-01x(51)=2.000000e-02, f=9.900990e-01, N=5.666156e-01, S=5.757530e-01x(52)=4.000000e-02, f=9.615385e-01, N=5.645415e-01, S=5.734575e-01x(53)=6.000000e-02, f=9.174312e-01, N=5.610925e-01, S=5.696316e-01x(54)=8.000000e-02, f=8.620690e-01, N=5.562800e-01, S=5.642753e-01x(55)=1.000000e-01, f=8.000000e-01, N=5.501202e-01, S=5.573887e-01x(56)=1.200000e-01, f=7.352941e-01, N=5.426338e-01, S=5.489717e-01x(57)=1.400000e-01, f=6.711409e-01, N=5.338463e-01, S=5.390243e-01x(58)=1.600000e-01, f=6.097561e-01, N=5.237877e-01, S=5.275466e-01x(59)=1.800000e-01, f=5.524862e-01, N=5.124925e-01, S=5.145385e-01x(60)=2.000000e-01, f=5.000000e-01, N=5.000000e-01, S=5.000000e-01x(61)=2.200000e-01, f=4.524887e-01, N=4.863540e-01, S=4.839577e-01x(62)=2.400000e-01, f=4.098361e-01, N=4.716031e-01, S=4.665441e-01x(63)=2.600000e-01, f=3.717472e-01, N=4.558002e-01, S=4.479184e-01x(64)=2.800000e-01, f=3.378378e-01, N=4.390031e-01, S=4.282397e-01x(65)=3.000000e-01, f=3.076923e-01, N=4.212740e-01, S=4.076670e-01x(66)=3.200000e-01, f=2.808989e-01, N=4.026800e-01, S=3.863595e-01x(67)=3.400000e-01, f=2.570694e-01, N=3.832925e-01, S=3.644763e-01x(68)=3.600000e-01, f=2.358491e-01, N=3.631877e-01, S=3.421765e-01x(69)=3.800000e-01, f=2.169197e-01, N=3.424463e-01, S=3.196192e-01x(70)=4.000000e-01, f=2.000000e-01, N=3.211538e-01, S=2.969636e-01x(71)=4.200000e-01, f=1.848429e-01, N=2.994002e-01, S=2.743686e-01x(72)=4.400000e-01, f=1.712329e-01, N=2.772800e-01, S=2.519935e-01x(73)=4.600000e-01, f=1.589825e-01, N=2.548925e-01, S=2.299974e-01x(74)=4.800000e-01, f=1.479290e-01, N=2.323415e-01, S=2.085393e-01x(75)=5.000000e-01, f=1.379310e-01, N=2.097356e-01, S=1.877783e-01x(76)=5.200000e-01, f=1.288660e-01, N=1.871877e-01, S=1.678737e-01x(77)=5.400000e-01, f=1.206273e-01, N=1.648156e-01, S=1.489844e-01x(78)=5.600000e-01, f=1.131222e-01, N=1.427415e-01, S=1.312696e-01x(79)=5.800000e-01, f=1.062699e-01, N=1.210925e-01, S=1.148885e-01x(80)=6.000000e-01, f=1.000000e-01, N=1.000000e-01, S=1.000000e-01x(81)=6.200000e-01, f=9.425071e-02, N=7.960019e-02, S=8.672308e-02x(82)=6.400000e-01, f=8.896797e-02, N=6.003385e-02, S=7.501538e-02x(83)=6.600000e-01, f=8.410429e-02, N=4.144635e-02, S=6.479433e-02x(84)=6.800000e-01, f=7.961783e-02, N=2.398769e-02, S=5.597733e-02x(85)=7.000000e-01, f=7.547170e-02, N=7.812500e-03, S=4.848178e-02x(86)=7.200000e-01, f=7.163324e-02, N=-6.920000e-03, S=4.222510e-02x(87)=7.400000e-01, f=6.807352e-02, N=-2.004596e-02, S=3.712470e-02x(88)=7.600000e-01, f=6.476684e-02, N=-3.139692e-02, S=3.309798e-02x(89)=7.800000e-01, f=6.169031e-02, N=-4.079981e-02, S=3.006235e-02x(90)=8.000000e-01, f=5.882353e-02, N=-4.807692e-02, S=2.793522e-02x(91)=8.200000e-01, f=5.614823e-02, N=-5.304596e-02, S=2.663401e-02x(92)=8.400000e-01, f=5.364807e-02, N=-5.552000e-02, S=2.607611e-02x(93)=8.600000e-01, f=5.130836e-02, N=-5.530750e-02, S=2.617895e-02x(94)=8.800000e-01, f=4.911591e-02, N=-5.221231e-02, S=2.685992e-02x(95)=9.000000e-01, f=4.705882e-02, N=-4.603365e-02, S=2.803644e-02x(96)=9.200000e-01, f=4.512635e-02, N=-3.656615e-02, S=2.962591e-02x(97)=9.400000e-01, f=4.330879e-02, N=-2.359981e-02, S=3.154575e-02x(98)=9.600000e-01, f=4.159734e-02, N=-6.920000e-03, S=3.371336e-02x(99)=9.800000e-01, f=3.998401e-02, N=1.369250e-02, S=3.604615e-02当n=10时,给定点xi的f(xi),N(xi),S(xi),分别为:x(1)=-9.800000e-01, f=3.998401e-02, N=1.230317e+00, S=4.022710e-02x(2)=-9.600000e-01, f=4.159734e-02, N=1.804385e+00, S=4.200907e-02x(3)=-9.400000e-01, f=4.330879e-02, N=1.958952e+00, S=4.382384e-02x(4)=-9.200000e-01, f=4.512635e-02, N=1.845845e+00, S=4.568782e-02x(5)=-9.000000e-01, f=4.705882e-02, N=1.578721e+00, S=4.761740e-02x(6)=-8.800000e-01, f=4.911591e-02, N=1.240213e+00, S=4.962900e-02x(7)=-8.600000e-01, f=5.130836e-02, N=8.880811e-01, S=5.173901e-02x(8)=-8.400000e-01, f=5.364807e-02, N=5.604444e-01, S=5.396383e-02x(9)=-8.200000e-01, f=5.614823e-02, N=2.802176e-01, S=5.631987e-02x(10)=-8.000000e-01, f=5.882353e-02, N=5.882353e-02, S=5.882353e-02x(11)=-7.800000e-01, f=6.169031e-02, N=-1.007243e-01, S=6.149562e-02x(12)=-7.600000e-01, f=6.476684e-02, N=-2.012964e-01, S=6.437461e-02x(13)=-7.400000e-01, f=6.807352e-02, N=-2.496082e-01, S=6.750337e-02x(14)=-7.200000e-01, f=7.163324e-02, N=-2.546027e-01, S=7.092479e-02x(15)=-7.000000e-01, f=7.547170e-02, N=-2.261963e-01, S=7.468173e-02x(16)=-6.800000e-01, f=7.961783e-02, N=-1.743355e-01, S=7.881707e-02x(17)=-6.600000e-01, f=8.410429e-02, N=-1.083152e-01, S=8.337369e-02x(18)=-6.400000e-01, f=8.896797e-02, N=-3.631685e-02, S=8.839447e-02x(19)=-6.200000e-01, f=9.425071e-02, N=3.487332e-02, S=9.392228e-02x(20)=-6.000000e-01, f=1.000000e-01, N=1.000000e-01, S=1.000000e-01x(21)=-5.800000e-01, f=1.062699e-01, N=1.553586e-01, S=1.066700e-01x(22)=-5.600000e-01, f=1.131222e-01, N=1.987262e-01, S=1.139730e-01x(23)=-5.400000e-01, f=1.206273e-01, N=2.292273e-01, S=1.219491e-01x(24)=-5.200000e-01, f=1.288660e-01, N=2.471535e-01, S=1.306384e-01x(25)=-5.000000e-01, f=1.379310e-01, N=2.537555e-01, S=1.400810e-01x(26)=-4.800000e-01, f=1.479290e-01, N=2.510206e-01, S=1.503172e-01x(27)=-4.600000e-01, f=1.589825e-01, N=2.414494e-01, S=1.613870e-01x(28)=-4.400000e-01, f=1.712329e-01, N=2.278397e-01, S=1.733307e-01x(29)=-4.200000e-01, f=1.848429e-01, N=2.130858e-01, S=1.861883e-01x(30)=-4.000000e-01, f=2.000000e-01, N=2.000000e-01, S=2.000000e-01x(31)=-3.800000e-01, f=2.169197e-01, N=1.911589e-01, S=2.149065e-01x(32)=-3.600000e-01, f=2.358491e-01, N=1.887784e-01, S=2.314509e-01x(33)=-3.400000e-01, f=2.570694e-01, N=1.946178e-01, S=2.502767e-01x(34)=-3.200000e-01, f=2.808989e-01, N=2.099145e-01, S=2.720276e-01x(35)=-3.000000e-01, f=3.076923e-01, N=2.353466e-01, S=2.973471e-01x(36)=-2.800000e-01, f=3.378378e-01, N=2.710241e-01, S=3.268788e-01x(37)=-2.600000e-01, f=3.717472e-01, N=3.165048e-01, S=3.612664e-01S=4.011534e-01x(39)=-2.200000e-01, f=4.524887e-01, N=4.325960e-01, S=4.471834e-01x(40)=-2.000000e-01, f=5.000000e-01, N=5.000000e-01, S=5.000000e-01x(41)=-1.800000e-01, f=5.524862e-01, N=5.709536e-01, S=5.597038e-01x(42)=-1.600000e-01, f=6.097561e-01, N=6.431626e-01, S=6.242233e-01x(43)=-1.400000e-01, f=6.711409e-01, N=7.142283e-01, S=6.909440e-01x(44)=-1.200000e-01, f=7.352941e-01, N=7.817471e-01, S=7.572512e-01x(45)=-1.000000e-01, f=8.000000e-01, N=8.434074e-01, S=8.205306e-01x(46)=-8.000000e-02, f=8.620690e-01, N=8.970803e-01, S=8.781675e-01x(47)=-6.000000e-02, f=9.174312e-01, N=9.409023e-01, S=9.275474e-01x(48)=-4.000000e-02, f=9.615385e-01, N=9.733459e-01, S=9.660558e-01x(49)=-2.000000e-02, f=9.900990e-01, N=9.932776e-01, S=9.910782e-01x(50)=0, f=1, N=1.000000e+00, S=1x(51)=2.000000e-02, f=9.900990e-01, N=9.932776e-01, S=9.910782e-01x(52)=4.000000e-02, f=9.615385e-01, N=9.733459e-01, S=9.660558e-01x(53)=6.000000e-02, f=9.174312e-01, N=9.409023e-01, S=9.275474e-01S=8.781675e-01x(55)=1.000000e-01, f=8.000000e-01, N=8.434074e-01, S=8.205306e-01x(56)=1.200000e-01, f=7.352941e-01, N=7.817471e-01, S=7.572512e-01x(57)=1.400000e-01, f=6.711409e-01, N=7.142283e-01, S=6.909440e-01x(58)=1.600000e-01, f=6.097561e-01, N=6.431626e-01, S=6.242233e-01x(59)=1.800000e-01, f=5.524862e-01, N=5.709536e-01, S=5.597038e-01x(60)=2.000000e-01, f=5.000000e-01, N=5.000000e-01, S=5.000000e-01x(61)=2.200000e-01, f=4.524887e-01, N=4.325960e-01, S=4.471834e-01x(62)=2.400000e-01, f=4.098361e-01, N=3.708328e-01, S=4.011534e-01x(63)=2.600000e-01, f=3.717472e-01, N=3.165048e-01, S=3.612664e-01x(64)=2.800000e-01, f=3.378378e-01, N=2.710241e-01, S=3.268788e-01x(65)=3.000000e-01, f=3.076923e-01, N=2.353466e-01, S=2.973471e-01x(66)=3.200000e-01, f=2.808989e-01, N=2.099145e-01, S=2.720276e-01x(67)=3.400000e-01, f=2.570694e-01, N=1.946178e-01, S=2.502767e-01x(68)=3.600000e-01, f=2.358491e-01, N=1.887784e-01, S=2.314509e-01x(69)=3.800000e-01, f=2.169197e-01, N=1.911589e-01, S=2.149065e-01S=2.000000e-01x(71)=4.200000e-01, f=1.848429e-01, N=2.130858e-01, S=1.861883e-01x(72)=4.400000e-01, f=1.712329e-01, N=2.278397e-01, S=1.733307e-01x(73)=4.600000e-01, f=1.589825e-01, N=2.414494e-01, S=1.613870e-01x(74)=4.800000e-01, f=1.479290e-01, N=2.510206e-01, S=1.503172e-01x(75)=5.000000e-01, f=1.379310e-01, N=2.537555e-01, S=1.400810e-01x(76)=5.200000e-01, f=1.288660e-01, N=2.471535e-01, S=1.306384e-01x(77)=5.400000e-01, f=1.206273e-01, N=2.292273e-01, S=1.219491e-01x(78)=5.600000e-01, f=1.131222e-01, N=1.987262e-01, S=1.139730e-01x(79)=5.800000e-01, f=1.062699e-01, N=1.553586e-01, S=1.066700e-01x(80)=6.000000e-01, f=1.000000e-01, N=1.000000e-01, S=1.000000e-01x(81)=6.200000e-01, f=9.425071e-02, N=3.487332e-02, S=9.392228e-02x(82)=6.400000e-01, f=8.896797e-02, N=-3.631685e-02, S=8.839447e-02x(83)=6.600000e-01, f=8.410429e-02, N=-1.083152e-01, S=8.337369e-02x(84)=6.800000e-01, f=7.961783e-02, N=-1.743355e-01, S=7.881707e-02x(85)=7.000000e-01, f=7.547170e-02, N=-2.261963e-01, S=7.468173e-02x(86)=7.200000e-01, f=7.163324e-02, N=-2.546027e-01, S=7.092479e-02x(87)=7.400000e-01, f=6.807352e-02, N=-2.496082e-01, S=6.750337e-02x(88)=7.600000e-01, f=6.476684e-02, N=-2.012964e-01, S=6.437461e-02x(89)=7.800000e-01, f=6.169031e-02, N=-1.007243e-01, S=6.149562e-02x(90)=8.000000e-01, f=5.882353e-02, N=5.882353e-02, S=5.882353e-02x(91)=8.200000e-01, f=5.614823e-02, N=2.802176e-01, S=5.631987e-02x(92)=8.400000e-01, f=5.364807e-02, N=5.604444e-01, S=5.396383e-02x(93)=8.600000e-01, f=5.130836e-02, N=8.880811e-01, S=5.173901e-02x(94)=8.800000e-01, f=4.911591e-02, N=1.240213e+00, S=4.962900e-02x(95)=9.000000e-01, f=4.705882e-02, N=1.578721e+00, S=4.761740e-02x(96)=9.200000e-01, f=4.512635e-02, N=1.845845e+00, S=4.568782e-02x(97)=9.400000e-01, f=4.330879e-02, N=1.958952e+00, S=4.382384e-02x(98)=9.600000e-01, f=4.159734e-02, N=1.804385e+00, S=4.200907e-02x(99)=9.800000e-01, f=3.998401e-02, N=1.230317e+00, S=4.022710e-02当n=20时,给定点xi的f(xi),N(xi),S(xi),分别为:x(1)=-9.800000e-01, f=3.998401e-02, N=-5.823814e+01, S=4.006530e-02x(2)=-9.600000e-01, f=4.159734e-02, N=-5.086442e+01, S=4.169799e-02x(3)=-9.400000e-01, f=4.330879e-02, N=-2.866257e+01, S=4.338852e-02x(4)=-9.200000e-01, f=4.512635e-02, N=-1.033451e+01, S=4.516583e-02x(5)=-9.000000e-01, f=4.705882e-02, N=4.705882e-02, S=4.705882e-02x(6)=-8.800000e-01, f=4.911591e-02, N=3.945073e+00, S=4.909285e-02x(7)=-8.600000e-01, f=5.130836e-02, N=4.069132e+00, S=5.127892e-02x(8)=-8.400000e-01, f=5.364807e-02, N=2.674355e+00, S=5.362444e-02x(9)=-8.200000e-01, f=5.614823e-02, N=1.135307e+00, S=5.613684e-02x(10)=-8.000000e-01, f=5.882353e-02, N=5.882353e-02, S=5.882353e-02x(11)=-7.800000e-01, f=6.169031e-02, N=-4.458677e-01, S=6.169466e-02x(12)=-7.600000e-01, f=6.476684e-02, N=-5.135540e-01, S=6.477126e-02x(13)=-7.400000e-01, f=6.807352e-02, N=-3.458790e-01, S=6.807713e-02x(14)=-7.200000e-01, f=7.163324e-02, N=-1.143479e-01, S=7.163601e-02x(15)=-7.000000e-01, f=7.547170e-02, N=7.547170e-02, S=7.547170e-02x(16)=-6.800000e-01, f=7.961783e-02, N=1.822831e-01, S=7.961088e-02x(17)=-6.600000e-01, f=8.410429e-02, N=2.100928e-01, S=8.409196e-02x(18)=-6.400000e-01, f=8.896797e-02, N=1.857752e-01, S=8.895628e-02x(19)=-6.200000e-01, f=9.425071e-02, N=1.408043e-01, S=9.424518e-02x(20)=-6.000000e-01, f=1.000000e-01, N=1.000000e-01, S=1.000000e-01x(21)=-5.800000e-01, f=1.062699e-01, N=7.704978e-02, S=1.062678e-01x(22)=-5.600000e-01, f=1.131222e-01, N=7.501127e-02, S=1.131189e-01x(23)=-5.400000e-01, f=1.206273e-01, N=8.956400e-02, S=1.206291e-01x(24)=-5.200000e-01, f=1.288660e-01, N=1.130482e-01, S=1.288745e-01x(25)=-5.000000e-01, f=1.379310e-01, N=1.379310e-01, S=1.379310e-01x(26)=-4.800000e-01, f=1.479290e-01, N=1.590076e-01, S=1.478903e-01x(27)=-4.600000e-01, f=1.589825e-01, N=1.742122e-01, S=1.589067e-01x(28)=-4.400000e-01, f=1.712329e-01, N=1.842980e-01, S=1.711504e-01x(29)=-4.200000e-01, f=1.848429e-01, N=1.918355e-01, S=1.847915e-01x(30)=-4.000000e-01, f=2.000000e-01, N=2.000000e-01, S=2.000000e-01x(31)=-3.800000e-01, f=2.169197e-01, N=2.115320e-01, S=2.169635e-01x(32)=-3.600000e-01, f=2.358491e-01, N=2.280983e-01, S=2.359395e-01S=2.572030e-01x(34)=-3.200000e-01, f=2.808989e-01, N=2.770218e-01, S=2.810290e-01x(35)=-3.000000e-01, f=3.076923e-01, N=3.076923e-01, S=3.076923e-01x(36)=-2.800000e-01, f=3.378378e-01, N=3.410637e-01, S=3.375225e-01x(37)=-2.600000e-01, f=3.717472e-01, N=3.765481e-01, S=3.710667e-01x(38)=-2.400000e-01, f=4.098361e-01, N=4.142700e-01, S=4.089266e-01x(39)=-2.200000e-01, f=4.524887e-01, N=4.550259e-01, S=4.517038e-01x(40)=-2.000000e-01, f=5.000000e-01, N=5.000000e-01, S=5.000000e-01x(41)=-1.800000e-01, f=5.524862e-01, N=5.503136e-01, S=5.540542e-01x(42)=-1.600000e-01, f=6.097561e-01, N=6.065255e-01, S=6.126552e-01x(43)=-1.400000e-01, f=6.711409e-01, N=6.682034e-01, S=6.742291e-01x(44)=-1.200000e-01, f=7.352941e-01, N=7.336720e-01, S=7.372020e-01x(45)=-1.000000e-01, f=8.000000e-01, N=8.000000e-01, S=8.000000e-01x(46)=-8.000000e-02, f=8.620690e-01, N=8.632436e-01, S=8.605990e-01x(47)=-6.000000e-02, f=9.174312e-01, N=9.189083e-01, S=9.151739e-01x(48)=-4.000000e-02, f=9.615385e-01, N=9.625511e-01, S=9.594493e-01S=9.891498e-01x(50)=0, f=1, N=1.000000e+00, S=1.000000e+00 x(51)=2.000000e-02, f=9.900990e-01, N=9.904176e-01, S=9.891498e-01x(52)=4.000000e-02, f=9.615385e-01, N=9.625511e-01, S=9.594493e-01x(53)=6.000000e-02, f=9.174312e-01, N=9.189083e-01, S=9.151739e-01x(54)=8.000000e-02, f=8.620690e-01, N=8.632436e-01, S=8.605990e-01x(55)=1.000000e-01, f=8.000000e-01, N=8.000000e-01, S=8.000000e-01x(56)=1.200000e-01, f=7.352941e-01, N=7.336720e-01, S=7.372020e-01x(57)=1.400000e-01, f=6.711409e-01, N=6.682034e-01, S=6.742291e-01x(58)=1.600000e-01, f=6.097561e-01, N=6.065255e-01, S=6.126552e-01x(59)=1.800000e-01, f=5.524862e-01, N=5.503136e-01, S=5.540542e-01x(60)=2.000000e-01, f=5.000000e-01, N=5.000000e-01, S=5.000000e-01x(61)=2.200000e-01, f=4.524887e-01, N=4.550259e-01, S=4.517038e-01x(62)=2.400000e-01, f=4.098361e-01, N=4.142700e-01, S=4.089266e-01x(63)=2.600000e-01, f=3.717472e-01, N=3.765481e-01, S=3.710667e-01x(64)=2.800000e-01, f=3.378378e-01, N=3.410637e-01, S=3.375225e-01S=3.076923e-01x(66)=3.200000e-01, f=2.808989e-01, N=2.770218e-01, S=2.810290e-01x(67)=3.400000e-01, f=2.570694e-01, N=2.501226e-01, S=2.572030e-01x(68)=3.600000e-01, f=2.358491e-01, N=2.280983e-01, S=2.359395e-01x(69)=3.800000e-01, f=2.169197e-01, N=2.115320e-01, S=2.169635e-01x(70)=4.000000e-01, f=2.000000e-01, N=2.000000e-01, S=2.000000e-01x(71)=4.200000e-01, f=1.848429e-01, N=1.918355e-01, S=1.847915e-01x(72)=4.400000e-01, f=1.712329e-01, N=1.842980e-01, S=1.711504e-01x(73)=4.600000e-01, f=1.589825e-01, N=1.742122e-01, S=1.589067e-01x(74)=4.800000e-01, f=1.479290e-01, N=1.590076e-01, S=1.478903e-01x(75)=5.000000e-01, f=1.379310e-01, N=1.379310e-01, S=1.379310e-01x(76)=5.200000e-01, f=1.288660e-01, N=1.130482e-01, S=1.288745e-01x(77)=5.400000e-01, f=1.206273e-01, N=8.956400e-02, S=1.206291e-01x(78)=5.600000e-01, f=1.131222e-01, N=7.501127e-02, S=1.131189e-01x(79)=5.800000e-01, f=1.062699e-01, N=7.704978e-02, S=1.062678e-01x(80)=6.000000e-01, f=1.000000e-01, N=1.000000e-01, S=1.000000e-01x(81)=6.200000e-01, f=9.425071e-02, N=1.408043e-01, S=9.424518e-02x(82)=6.400000e-01, f=8.896797e-02, N=1.857752e-01, S=8.895628e-02x(83)=6.600000e-01, f=8.410429e-02, N=2.100928e-01, S=8.409196e-02x(84)=6.800000e-01, f=7.961783e-02, N=1.822831e-01, S=7.961088e-02x(85)=7.000000e-01, f=7.547170e-02, N=7.547170e-02, S=7.547170e-02x(86)=7.200000e-01, f=7.163324e-02, N=-1.143479e-01, S=7.163601e-02x(87)=7.400000e-01, f=6.807352e-02, N=-3.458790e-01, S=6.807713e-02x(88)=7.600000e-01, f=6.476684e-02, N=-5.135540e-01, S=6.477126e-02x(89)=7.800000e-01, f=6.169031e-02, N=-4.458677e-01, S=6.169466e-02x(90)=8.000000e-01, f=5.882353e-02, N=5.882353e-02, S=5.882353e-02x(91)=8.200000e-01, f=5.614823e-02, N=1.135307e+00, S=5.613684e-02x(92)=8.400000e-01, f=5.364807e-02, N=2.674355e+00, S=5.362444e-02x(93)=8.600000e-01, f=5.130836e-02, N=4.069132e+00, S=5.127892e-02x(94)=8.800000e-01, f=4.911591e-02, N=3.945073e+00, S=4.909285e-02x(95)=9.000000e-01, f=4.705882e-02, N=4.705882e-02, S=4.705882e-02x(96)=9.200000e-01, f=4.512635e-02, N=-1.033451e+01, S=4.516583e-02x(97)=9.400000e-01, f=4.330879e-02, N=-2.866257e+01, S=4.338852e-02x(98)=9.600000e-01, f=4.159734e-02, N=-5.086442e+01, S=4.169799e-02x(99)=9.800000e-01, f=3.998401e-02, N=-5.823814e+01, S=4.006530e-02第四问当n=5时,Newton插值的最大误差E(N)和三次样条插值的最大误差E(S)分别为:E(N)=4.326923e-01 E(S)=4.234818e-01当n=10时,Newton插值的最大误差E(N)和三次样条插值的最大误差E(S)分别为:E(N)=1.915643e+00 E(S)=2.195711e-02当n=20时,Newton插值的最大误差E(N)和三次样条插值的最大误差E(S)分别为:E(N)=5.827813e+01 E(S)=3.088180e-03结果分析:由上面的结果显示,使用Newton插值多项式出现随着n的增大,误差也逐渐增大的现象,其最大误差达到58.27813,而相应的三次样条插值多项式随着n的增大,误差逐渐减小,n=20的误差仅为0.003088。

相关主题