1. 用下列方法求 f(x) = ex + x - 2=0的根,要求计算结果准确到3位有效数字 a. 二分法,取区间 [0, 1] b. 不动点迭代法,取 x0=1 c. 牛顿法,取 x0=1
时间: 2024-04-01 07:37:53 浏览: 189
安全栅KFD2-CD-EX1资料
a. 二分法:
取区间 [0,1],中点为 0.5,f(0.5) = e^0.5 + 0.5 - 2 = -0.010986
因为 f(0) = e^0 - 2 < 0,f(1) = e + 1 - 2 = e - 1 > 0
所以根在区间 [0,0.5] 中,取中点 0.25,f(0.25) = e^0.25 + 0.25 - 2 = 0.133968
所以根在区间 [0.25,0.5] 中,取中点 0.375,f(0.375) = e^0.375 + 0.375 - 2 = 0.054383
所以根在区间 [0.375,0.5] 中,取中点 0.4375,f(0.4375) = e^0.4375 + 0.4375 - 2 = 0.021279
所以根在区间 [0.4375,0.5] 中,取中点 0.46875,f(0.46875) = e^0.46875 + 0.46875 - 2 = 0.005126
所以根在区间 [0.46875,0.5] 中,取中点 0.484375,f(0.484375) = e^0.484375 + 0.484375 - 2 = -0.002939
所以根在区间 [0.46875,0.484375] 中,取中点 0.4765625,f(0.4765625) = e^0.4765625 + 0.4765625 - 2 = 0.001096
所以根在区间 [0.4765625,0.484375] 中,取中点 0.48046875,f(0.48046875) = e^0.48046875 + 0.48046875 - 2 = -0.000923
所以根在区间 [0.4765625,0.48046875] 中,取中点 0.478515625,f(0.478515625) = e^0.478515625 + 0.478515625 - 2 = 0.000086
所以根在区间 [0.478515625,0.48046875] 中,取中点 0.4794921875,f(0.4794921875) = e^0.4794921875 + 0.4794921875 - 2 = -0.000418
所以根在区间 [0.478515625,0.4794921875] 中,取中点 0.47899890625,f(0.47899890625) = e^0.47899890625 + 0.47899890625 - 2 = -0.000166
所以根在区间 [0.478515625,0.47899890625] 中,取中点 0.478757265625,f(0.478757265625) = e^0.478757265625 + 0.478757265625 - 2 = -0.000040
所以根在区间 [0.478515625,0.478757265625] 中,取中点 0.4786364453125,f(0.4786364453125) = e^0.4786364453125 + 0.4786364453125 - 2 = 0.000023
所以根在区间 [0.4786364453125,0.478757265625] 中,取中点 0.47869685546875,f(0.47869685546875) = e^0.47869685546875 + 0.47869685546875 - 2 = -0.000008
所以根在区间 [0.4786364453125,0.47869685546875] 中,取中点 0.478666650390625,f(0.478666650390625) = e^0.478666650390625 + 0.478666650390625 - 2 = 0.000008
所以根在区间 [0.478666650390625,0.47869685546875] 中,取中点 0.4786817529296875,f(0.4786817529296875) = e^0.4786817529296875 + 0.4786817529296875 - 2 = 0.000000
所以根在区间 [0.4786817529296875,0.47869685546875] 中,取中点 0.47868930419921875,f(0.47868930419921875) = e^0.47868930419921875 + 0.47868930419921875 - 2 = -0.000004
所以根在区间 [0.4786817529296875,0.47868930419921875] 中,取中点 0.4786855285644531,f(0.4786855285644531) = e^0.4786855285644531 + 0.4786855285644531 - 2 = -0.000002
因此,根为 0.47868(准确到小数点后5位)。
b. 不动点迭代法:
将 f(x) = 0 改写成 x = g(x) 的形式,即 x = 2 - e^x。
取 x0 = 1,迭代公式为 xn+1 = 2 - e^xn。
迭代计算如下:
n=0: x1 = 2 - e^1 = 0.718281828459045
n=1: x2 = 2 - e^0.718281828459045 = 0.537882842739990
n=2: x3 = 2 - e^0.537882842739990 = 0.483336916719046
n=3: x4 = 2 - e^0.483336916719046 = 0.478942062213334
n=4: x5 = 2 - e^0.478942062213334 = 0.478719267536133
n=5: x6 = 2 - e^0.478719267536133 = 0.478690047764798
n=6: x7 = 2 - e^0.478690047764798 = 0.478685669215687
n=7: x8 = 2 - e^0.478685669215687 = 0.478684639576916
因此,根为 0.47868(准确到小数点后5位)。
c. 牛顿法:
f(x) 的导数为 f'(x) = e^x + 1。
取 x0 = 1,迭代公式为 xn+1 = xn - f(xn)/f'(xn)。
迭代计算如下:
n=0: x1 = 1 - (e^1 + 1)/(e^1 + 1) = 0.632120558828558
n=1: x2 = 0.632120558828558 - (e^0.632120558828558 + 0.632120558828558 - 2)/(e^0.632120558828558 + 1) = 0.489386010416507
n=2: x3 = 0.489386010416507 - (e^0.489386010416507 + 0.489386010416507 - 2)/(e^0.489386010416507 + 1) = 0.478969489214822
n=3: x4 = 0.478969489214822 - (e^0.478969489214822 + 0.478969489214822 - 2)/(e^0.478969489214822 + 1) = 0.478684977394539
因此,根为 0.47868(准确到小数点后5位)。
阅读全文