题目
用迭代法求方程 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 =0x 0 =0
解析
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∗≈x
4
=0.090512616674365