牛顿迭代法matlab求方程,请帮忙,牛顿迭代法解非线性方程,Matlab程序报错

我的主程序是

function [z,k] = newton(y0,n,eps1)

k=1;

z=y0;

t=y0-fun0(y0)./dfun0(y0);

while abs(t-y0)>=eps1

z=[z,t];

y0=t;

k=k+1;

t=y0-fun0(y0)./dfun0(y0);

if (k-1)>n

error('n is full');

end

end

end

其中调用了fun0和dfun0两个函数,funo函数程序为

function [fun] = fun0(y)

fun=49550.*log(5000000) - 49550.*log(y - (y.*exp(y./17520000))./25 + 5000000) - (1238750.*((5000000.*log(y + 5000000))./exp(y./17520000) - (5000000.*log(y - (y.*exp(y./17520000))./25 + 5000000))./exp(y./17520000)))./y + ((991.*y)./2 + 100).*((2500.*(5000000./(exp(y./17520000).*(y + 5000000)) - (125.*log(y + 5000000))./(438.*exp(y./17520000)) + (125.*log(y - (y.*exp(y./17520000))./25 + 5000000))./(438.*exp(y./17520000)) + (5000000.*(exp(y./17520000)./25 + (y.*exp(y./17520000))./438000000 - 1))./(exp(y./17520000).*(y - (y.*exp(y./17520000))./25 + 5000000))))./y - (2500.*((5000000.*log(y + 5000000))./exp(y./17520000) - (5000000.*log(y - (y.*exp(y./17520000))./25 + 5000000))./exp(y./17520000)))./y.^2 + 2500./(exp(y./17520000).*(y + 5000000)) - (100.*(exp(y./17520000)./25 + (y.*exp(y./17520000))./438000000 - 1))./(y - (y.*exp(y./17520000))./25 + 5000000) - log(y + 5000000)./(7008.*exp(y./17520000)) + log(y - (y.*exp(y./17520000))./25 + 5000000)./(7008.*exp(y./17520000)) + (2500.*(exp(y./17520000)./25 + (y.*exp(y./17520000))./438000000 - 1))/(exp(y./17520000).*(y - (y.*exp(y./17520000))./25 + 5000000))) - (1238750.*log(y + 5000000))./exp(y./17520000) + (1238750.*log(y - (y.*exp(y./17520000))./25 + 5000000))./exp(y./17520000) + 49550;

end

运行结果为

》[z,k] = newton(2000,40,0.0001)

??? Undefined function or method 'ge' for input arguments of type 'sym'.

Error in ==> newton at 5

while abs(t-y0)>=eps1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值