用迭代法求方程 e x p ( x ) + 10 ∗ x − 2 = 0 exp(x) + 10*x -2=0 exp(x)+10∗x−2=0 的根,要求根有3位小数,初值 x 0 = 0 x_0 =0 x0=0
迭代方程: x k + 1 = ( 2 − e x k ) / 10 x_{k+1}=(2-e^{x_{k}})/10 xk+1=(2−exk)/10
当 x k ∈ [ 0 , 0.5 ] x_{k}∈[0, 0.5] xk∈[0,0.5] 时, φ ( x k ) = ( 2 − e x k ) / 10 ∈ [ 0 , 0.5 ] φ(x_{k})=(2-e^{x_{k}})/10 ∈[0, 0.5] φ(xk)=(2−exk)/10∈[0,0.5]
∣ φ ′ ( x k ) ∣ = ∣ − e x k ∣ / 10 ≤ L < 1 , L = e 0.5 / 10 = 0.165 |φ'(x_{k})| =|-e^{x_k}|/10≤L<1,L=e^{0.5}/10=0.165 ∣φ′(xk)∣=∣−exk∣/10≤L<1,L=e0.5/10=0.165
故 x k + 1 = ( 2 − e x k ) / 10 x_{k+1}=(2-e^{x_{k}})/10 xk+1=(2−exk)/10 在[0, 0.5]上整体收敛
由 ∣ x k − x ∗ ∣ ≤ ∣ x k − x k + 1 ∣ ∗ L / ( 1 − L ) < 1 0 − 4 / 2 |x_k - x*|≤ |x_k - x_{k+1}| *L/(1-L)<10^{-4}/2 ∣xk−x∗∣≤∣xk−xk+1∣∗L/(1−L)<10−4/2
得: ∣ x k − x k + 1 ∣ < ( ( 1 − L ) / L ) ∗ 1 0 − 4 / 2 < 1 0 − 6 |x_k - x_{k+1}| <((1-L)/L)*10^{-4}/2 <10^{-6} ∣xk−xk+1∣<((1−L)/L)∗10−4/2<10−6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 简介:用迭代法求方程exp(x) + 10*x -2=0的根,要求根有3位小数
% 作者:不雨_亦潇潇
% 文件:dichotomy2.m
% 日期:20221013
% 博客:https://blog.csdn.net/weixin_43470383/article/details/127222948
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc; clear all;
syms x
x0 = 0;
x1 = (2-exp(x0)) / 10;
n = 1;
while abs(x0-x1)>10^(-6)
x0 = x1;
x1 = (2-exp(x0)) / 10
n = n+1
end
x0
x1 =
0.089482908192435
n =
2
x1 =
0.090639135859584
n =
3
x1 =
0.090512616674365
n =
4
x1 =
0.090526468052644
n =
5
x1 =
0.090524951682840
n =
6
x1 =
0.090525117687371
n =
7
x0 =
0.090524951682840
∣ x 6 − x 5 ∣ = 0.000001517 < 1 0 − 6 |x_{6}-x_{5}|=0.000001517<10^{-6} ∣x6−x5∣=0.000001517<10−6
故 x ∗ ≈ x 6 x*≈x_{6} x∗≈x6