用matlab如何编写牛顿迭代法问题,谢谢
2个回答
展开全部
function
[
A
]
=
cal(
a,b,v
)%a,b表示区间,v是
精度
i=1;
x
=
(a+b)/2;
A=[i
x];
t
=
x-(x^3-x-1)/(3*x^2-1);%迭代函数
while(abs(t-x)>v)
i=i+1;
x
=
t;
A
=
[A;i
x];
t
=
x-(x^3-x-1)/(3*x^2-1);%迭代函数
end
A
=
[A;i+1
t];
end
运行结果:
>>
format
long;
>>
cal(1,2,0.00001)
ans
=
1.000000000000000
1.500000000000000
2.000000000000000
1.347826086956522
3.000000000000000
1.325200398950907
4.000000000000000
1.324718173999054
5.000000000000000
1.324717957244790
[
A
]
=
cal(
a,b,v
)%a,b表示区间,v是
精度
i=1;
x
=
(a+b)/2;
A=[i
x];
t
=
x-(x^3-x-1)/(3*x^2-1);%迭代函数
while(abs(t-x)>v)
i=i+1;
x
=
t;
A
=
[A;i
x];
t
=
x-(x^3-x-1)/(3*x^2-1);%迭代函数
end
A
=
[A;i+1
t];
end
运行结果:
>>
format
long;
>>
cal(1,2,0.00001)
ans
=
1.000000000000000
1.500000000000000
2.000000000000000
1.347826086956522
3.000000000000000
1.325200398950907
4.000000000000000
1.324718173999054
5.000000000000000
1.324717957244790
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询