【数值分析】迭代法求方程的根(附matlab代码)

题目

迭代法求方程 e x p ( x ) + 10 ∗ x − 2 = 0 exp(x) + 10*x -2=0 exp(x)+10x2=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=(2exk)/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)=(2exk)/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∣/10L<1L=e0.5/10=0.165
x k + 1 = ( 2 − e x k ) / 10 x_{k+1}=(2-e^{x_{k}})/10 xk+1=(2exk)/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 xkxxkxk+1L/(1L)<104/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} xkxk+1((1L)/L)104/2<106

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)>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} x6x5=0.000001517<106
x ∗ ≈ x 6 x*≈x_{6} xx6

你可能感兴趣的:(#,数值分析,Matlab,1024程序员节,简单迭代,迭代,数值分析,matlab)