题目
用迭代法求方程 e x p ( x ) + 10 ∗ x − 2 = 0 exp(x) + 10*x -2=0exp(x)+10∗x−2=0 的根,要求根有3位小数,初值 x 0 = 0 x_0 =0x0=0
解析
迭代方程:x k + 1 = ( 2 − e x k ) / 10 x_{k+1}=(2-e^{x_{k}})/10xk+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}})/10xk+1=(2−exk)/10 在[0, 0.5]上整体收敛
Matlab代码
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 简介:用迭代法求方程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)>5*10^(-4) x0 = x1; x1 = (2-exp(x0)) / 10 n = n+1 end x1
运行结果
x1 =
0.089482908192435
n =
2
x1 =
0.090639135859584
n =
3
x1 =
0.090512616674365
n =
4
x1 =
0.090512616674365
x ∗ ≈ x 4 = 0.090512616674365 x*≈x_{4}=0.090512616674365x∗≈x4=0.090512616674365