最速下降法求解非线性方程组 两个方程可以求解 三个方程求解的时候系统出现输出参数太多 这是怎么回事啊。
1 view (last 30 days)
Show older comments
function [x, n, data] = zuisu(x0,tol)
% Szuisu 为最速下降法求解非线性方程组的函数
if nargin==1
tol=0.0001;
end
x1=x0-0.001*tidu8_22(x0);
n=1;
% 迭代过程
while (norm(x1-x0)>tol)&(n<2000)
x0=x1;
% 0.001 为步长因子
x1=x0-0.001*tidu8_22(x0);
n=n+1;
% data用来存放中间数据
data(:,n)=x1;
end
x=x1;
函数的梯度为:
function tidu8_22(x0)
a0=x0(1);
a1=x0(2);
b=x0(3);
f=[ 4*a0*(a0^2 + 2*a1^2 - 1) + 2*(2*a0*a1 - (3*a0*a1^3)/5 - (2*a0*a1^3)/(5*(2*a1*a0^2 + a1 + 10)) + (4*a0^3*a1^4)/(5*(2*a1*a0^2 + a1 + 10)^2))*(a1/2 - a1*b + a0^2*a1 + (9*a1^3)/50 - (3*a0^2*a1^3)/10 - (a0^2*a1^3)/(5*(2*a1*a0^2 + a1 + 10))) + 2*(a0*b - (9*a0)/10 - (18*a0*a1^2)/5 + (a0*a1^4)/25 + (a0^3*a1^2)/5)*((3*a0^2*a1^2)/5 + a1^4/25 - (18*a1^2)/5 + b - 9/10), 8*a1*(a0^2 + 2*a1^2 - 1) + 2*(a1/2 - a1*b + a0^2*a1 + (9*a1^3)/50 - (3*a0^2*a1^3)/10 - (a0^2*a1^3)/(5*(2*a1*a0^2 + a1 + 10)))*(a0^2 - b + (27*a1^2)/50 - (9*a0^2*a1^2)/10 - (3*a0^2*a1^2)/(5*(2*a1*a0^2 + a1 + 10)) + (a0^2*a1^3*(2*a0^2 + 1))/(5*(2*a1*a0^2 + a1 + 10)^2) + 1/2) + (2*a0^2*a1*(5*a0^2 + 2*a1^2 - 90)*(10*a0^2*a1^2 + 2*a1^4 - 180*a1^2 + 50*b - 45))/625, 2*a0^2*b + 2*a1^2*b - (9*a0^2)/5 - a1^2 - (9*a1^4)/25 - (46*a0^2*a1^2)/5 + (17*a0^2*a1^4)/25 + (2*a0^4*a1^2)/5 + (2*a0^2*a1^4)/(5*(2*a1*a0^2 + a1 + 10))];
clear all;
x0=[0 0 1];
[x,n]=zuisu(x0);
disp ('计算结果为:')
x
disp ('迭代次数为');
n
错误使用 tidu8_22
输出参数太多。
出错 zuisu (line 6)
x1=x0-0.001*tidu8_22(x0);
0 Comments
Accepted Answer
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!