Upload original Matlab程序设计 course files (part 4)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/DiffParam1.m+27-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/DiffParam2.m+36-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/SOR.m+40-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulBFS.m+32-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulConj.m+53-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulDFP.m+31-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulDNewton.m+35-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulDamp.m+60-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulDiscNewton.m+35-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulFastDown.m+30-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulGSND.m+29-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulGXF1.m+42-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulGXF2.m+52-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulMix.m+51-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulNewton.m+24-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulNewtonSOR.m+53-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulNewtonStev.m+36-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulNumYT.m+42-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulRank1.m+31-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulSimNewton.m+29-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulStablePoint.m+24-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulVNewton.m+38-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/Crout.m+22-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/Doolittle.m+22-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/GaussJordanXQ.m+36-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/GaussXQAllMain.m+58-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/GaussXQByOrder.m+19-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/GaussXQLineMain.m+34-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/InvAddSide.m+20-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/SymPos1.m+17-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/SymPos2.m+20-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/SymPos3.m+24-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/Yesf.m+26-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/conjgrad.m+29-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/followup.m+29-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/qrxq.m+17-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/BGS.m+42-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/BJ.m+48-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/BSOR.m+43-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/JOR.m+28-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/SOR.m+33-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/SSOR.m+38-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/conjgrad.m+18-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/crs.m+22-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/fastdown.m+16-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/gauseidel.m+26-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/grs.m+22-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/jacobi.m+30-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/preconjgrad.m+23-3
- matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/richason.m+22-3
123123456789101112131415161718192021222324252627version https://git-lfs.github.com/spec/v1oid sha256:ec6af3e85865e3b7e7baee7d2991144091b66aa928155300ec3a0c496be0ab30size 494function r=DiffParam1(F,x0,h,N)
%�����Է����飺f
%��ʼ�⣺x0
%��ֵ����������С��h
%�ſɱȵ�������:l
%��ľ��ȣ�eps
%��õ�һ��⣺r
%����������n
x0 = transpose(x0);
n = length(x0);
ht = 1/N;
Fx0 = subs(F,findsym(F),x0);
for k=1:N
Fx = subs(F,findsym(F),x0);
J = zeros(n,n);
for i=1:n
x1 = x0;
x1(i) = x1(i)+h(i);
J(:,i) = (subs(F,findsym(F),x1)-Fx)/h(i);
end
inJ = inv(J);
r = x0 - ht*inJ*Fx0;
x0 = r;
end
123123456789101112131415161718192021222324252627282930313233343536version https://git-lfs.github.com/spec/v1oid sha256:f3fee110be8639ff4104641fe7d2cf3eced14f5d88772cdce8023ee7bb2ebba4size 688function r=DiffParam2(F,x0,h,N)
%�����Է����飺f
%��ʼ�⣺x0
%��ֵ����������С��h
%�ſɱȵ�������:l
%��ľ��ȣ�eps
%��õ�һ��⣺r
%����������n
x0 = transpose(x0);
n = length(x0);
ht = 1/N;
Fx0 = subs(F,findsym(F),x0);
J = zeros(n,n);
for i=1:n
xt = x0;
xt(i) = xt(i)+h(i);
J(:,i) = (subs(F,findsym(F),xt)-Fx0)/h(i);
end
inJ = inv(J);
x1 = x0 - ht*inJ*Fx0;
for k=1:N
x2 = x1 + (x1-x0)/2;
Fx2 = subs(F,findsym(F),x2);
J = zeros(n,n);
for i=1:n
xt = x2;
xt(i) = xt(i)+h(i);
J(:,i) = (subs(F,findsym(F),xt)-Fx2)/h(i);
end
inJ = inv(J);
r = x1 - ht*inJ*Fx0;
x0 = x1;
x1 = r;
end12312345678910111213141516171819202122232425262728293031323334353637383940version https://git-lfs.github.com/spec/v1oid sha256:176f5d998ea37ed60a69bd6707506b5f25016286dd164116707f8d05da2b0d28size 849function [x,n]=SOR(A,b,x0,w,M,eps)
%���ó��ɳڵ����������Է�����Ax=b�Ľ�
%���Է������ϵ������A
%���Է������еij���������b
%������ʼ������x0
%�ɳ����ӣ�w
%��ľ��ȿ��ƣ�eps
%�����������ƣ�M
%���Է�����Ľ⣺x
%������辫�ȵĽ�ʵ�ʵĵ���������n
if nargin==4
eps= 1.0e-6;
M = 10000;
elseif nargin == 5
eps = 1.0e-6;
end
if(w<=0 || w>=2)
error;
return;
end
D=diag(diag(A)); %��A�ĶԽǾ���
L=-tril(A,-1); %��A����������
U=-triu(A,1); %��A����������
B=inv(D-L*w)*((1-w)*D+w*U);
f=w*inv((D-L*w))*b;
x=x0;
n=0; %��������
tol=1; %ǰ�����ε���������
while tol>=eps
x = B*x0+f; %������ʽ
n = n+1;
tol = norm(x-x0);
x0 = x;
if(n>=M)
disp('Warning: ��������̫�࣬���ܲ�������');
return;
end
end1231234567891011121314151617181920212223242526272829303132version https://git-lfs.github.com/spec/v1oid sha256:f08a5cb55989ad2be6e861e70800b9d1edf44be8c942e66d4c2861317a31a8dfsize 688function [r,n]=mulBFS(F,x0,B,eps)
if nargin==2
l = length(x0);
B=eye(l); %BȡΪ��λ��
eps=1.0e-4;
else
if nargin==3
eps=1.0e-4;
end
end
fx = subs(F,findsym(F),x0);
r=transpose(x0)-B*fx;
n=1;
tol=1;
while tol>eps
x0=r;
fx = subs(F,findsym(F),x0);
r=x0-B*fx;
y=r-x0;
fr = subs(F,findsym(F),r);
z = fr-fx;
u = 1 + z'*B*z/(y'*z);
B1= B+ (u*y*y'-B*z*y'-y*z'*B)/(y'*z); %����B
B=B1;
n=n+1;
if(n>100000) %������������
disp('��������̫�࣬���ܲ�������');
return;
end
tol=norm(r-x0);
end1231234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253version https://git-lfs.github.com/spec/v1oid sha256:1b23497ee33be76fb89414757c4573e0adc447e90e82c8733eaf9b5ec2054191size 1144function [r,m]=mulConj(F,x0,h,eps)
format long;
if nargin==3
eps=1.0e-6;
end
n = length(x0);
x0 = transpose(x0);
fx0 = subs(F,findsym(F),x0);
p0 = zeros(n,n);
for i=1:n
x1 = x0;
x1(i) = x1(i)*(1+h);
p0(:,i) = -(subs(F,findsym(F),x1)-fx0)/h;
end
m=1;
tol=1;
while tol>eps
fx = subs(F,findsym(F),x0);
J = zeros(n,n);
for i=1:n
x1 = x0;
x1(i) = x1(i)+h;
J(:,i) = (subs(F,findsym(F),x1)-fx)/h;
end
lamda = fx/sum(diag(transpose(J)*J));
r=x0+p0*lamda; %���ĵ�����ʽ
fr = subs(F,findsym(F),r);
Jnext = zeros(n,n);
for i=1:n
x1 = r;
x1(i) = x1(i)+h;
Jnext(:,i) = (subs(F,findsym(F),x1)-fr)/h;
end
abs1 = transpose(Jnext)*Jnext;
abs2 = transpose(J)*J;
v = abs1/abs2;
if (abs(det(v)) < 1)
p1 = -Jnext+p0*v;
else
p1 = -Jnext;
end
tol=norm(r-x0);
p0 = p1;
x0 = r;
m=m+1;
if(m>100000) %������������
disp('��������̫�࣬���ܲ�������');
return;
end
end
format short;12312345678910111213141516171819202122232425262728293031version https://git-lfs.github.com/spec/v1oid sha256:2836cd415947fcfdee4fbd299f0c2f251f854ebb46d4cc6fb8bc9449f90fdea6size 659function [r,n]=mulDFP(F,x0,A,eps)
if nargin==2
l = length(x0);
B=eye(l); %AȡΪ��λ��
eps=1.0e-4;
else
if nargin==3
eps=1.0e-4;
end
end
fx = subs(F,findsym(F),x0);
r=transpose(x0)-B*fx;
n=1;
tol=1;
while tol>eps
x0=r;
fx = subs(F,findsym(F),x0);
r=x0-B*fx;
y=r-x0;
fr = subs(F,findsym(F),r);
z = fr-fx;
B1=B+ y*y'/(y'*z)-B*z*z'*B/(z'*B*z); %����A
B=B1;
n=n+1;
if(n>100000) %������������
disp('��������̫�࣬���ܲ�������');
return;
end
tol=norm(r-x0);
end1231234567891011121314151617181920212223242526272829303132333435version https://git-lfs.github.com/spec/v1oid sha256:c558f9f3d3e2c49797512847949c3b0dc932fae37c038f97ed15091157e87804size 759function [r,m]=mulDNewton(F,x0,eps)
%�����Է����飺F
%��ʼ�⣺x0
%��ľ��ȣ�eps
%��õ�һ��⣺r
%����������n
if nargin==2
eps=1.0e-4;
end
x0 = transpose(x0);
dF = Jacobian(F);
m=1;
tol=1;
while tol>eps
ttol=1;
w=1;
Fx = subs(F,findsym(F),x0);
dFx = subs(dF,findsym(dF),x0);
F1=norm(Fx);
while ttol>=0 %�����ѭ����ѡȡ��ɽ����w�Ĺ���
r=x0-w*inv(dFx)*Fx; %���ĵĵ�����ʽ
Fr = subs(F,findsym(F),r);
ttol=norm(Fr)-F1;
w=w/2;
end
tol=norm(r-x0);
m=m+1;
x0=r;
if(m>100000) %������������
disp('��������̫�࣬���ܲ�������');
return;
end
end123123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960version https://git-lfs.github.com/spec/v1oid sha256:9c155bff68396b444c492850ca4976b0f5f0830657ac93bd4078c87e0f378689size 1247function [r,m]=mulDamp(F,x0,h,u,v,eps)
format long;
if nargin==5
eps=1.0e-6;
end
FI = transpose(F)*F/2;
n = length(x0);
x0 = transpose(x0);
m=1;
tol=1;
while tol>eps
j = 0;
fx = subs(F,findsym(F),x0);
J = zeros(n,n);
for i=1:n
x1 = x0;
x1(i) = x1(i)+h;
afx = subs(F,findsym(F),x1);
J(:,i) = (afx-fx)/h;
end
FIx = subs(FI,findsym(FI),x0);
for i=1:n
x2 = x0;
x2(i) = x2(i)+h;
gradFI(i,1) = (subs(FI,findsym(FI),x2)-FIx)/h;
end
s=0;
while s==0
A = transpose(J)*J+u*eye(n,n);
p = -A\gradFI;
r = x0 + p;
FIr = subs(FI,findsym(FI),r);
if FIr<FIx
if j == 0
u = u/v;
j = 1;
else
s=1;
end
else
u = u*v;
j = 1;
if norm(r-x0)<eps
s=1;
end
end
end
x0 = r;
tol = norm(p);
m=m+1;
if(m>100000) %������������
disp('��������̫�࣬���ܲ�������');
return;
end
end
format short;1231234567891011121314151617181920212223242526272829303132333435version https://git-lfs.github.com/spec/v1oid sha256:0d9ce44e390846088c5ca042a65230c072b07ea34b7dcfae25678d75503105ebsize 767function [r,m]=mulDiscNewton(F,x0,h,eps)
format long;
if nargin==3
eps=1.0e-8;
end
n = length(x0);
fx = subs(F,findsym(F),x0);
J = zeros(n,n);
for i=1:n
x1 = x0;
x1(i) = x1(i)+h(i);
J(:,i) = (subs(F,findsym(F),x1)-fx)/h(i);
end
r=transpose(x0)-inv(J)*fx;
m=1;
tol=1;
while tol>eps
xs=r;
fx = subs(F,findsym(F),xs);
J = zeros(n,n);
for i=1:n
x1 = xs;
x1(i) = x1(i)+h(i);
J(:,i) = (subs(F,findsym(F),x1)-fx)/h(i);
end
r=xs-inv(J)*fx; %���ĵ�����ʽ
tol=norm(r-xs);
m=m+1;
if(m>100000) %������������
disp('��������̫�࣬���ܲ�������');
return;
end
end
format short;123123456789101112131415161718192021222324252627282930version https://git-lfs.github.com/spec/v1oid sha256:3b407f93172ca23f1a22e464bd0b2c393bb1c47b6a310b1d231ba4af7f640f31size 654function [r,m]=mulFastDown(F,x0,h,eps)
format long;
if nargin==3
eps=1.0e-8;
end
n = length(x0);
x0 = transpose(x0);
m=1;
tol=1;
while tol>eps
fx = subs(F,findsym(F),x0);
J = zeros(n,n);
for i=1:n
x1 = x0;
x1(i) = x1(i)+h;
J(:,i) = (subs(F,findsym(F),x1)-fx)/h;
end
lamda = fx/sum(diag(transpose(J)*J));
r=x0-J*lamda; %���ĵ�����ʽ
fr = subs(F,findsym(F),r);
tol=dot(fr,fr);
x0 = r;
m=m+1;
if(m>100000) %������������
disp('��������̫�࣬���ܲ�������');
return;
end
end
format short;1231234567891011121314151617181920212223242526272829version https://git-lfs.github.com/spec/v1oid sha256:847ee90a2c248b69aba3b730828e0549a9d60f547eb39933493dbe6d795a8cbesize 613function [r,m]=mulGSND(F,x0,h,eps)
format long;
if nargin==3
eps=1.0e-8;
end
n = length(x0);
x0 = transpose(x0);
m=1;
tol=1;
while tol>eps
fx = subs(F,findsym(F),x0);
J = zeros(n,n);
for i=1:n
x1 = x0;
x1(i) = x1(i)+h;
J(:,i) = (subs(F,findsym(F),x1)-fx)/h;
end
DF = inv(transpose(J)*J)*transpose(J);
r=x0-DF*fx; %���ĵ�����ʽ
tol=norm(r-x0);
x0 = r;
m=m+1;
if(m>100000) %������������
disp('��������̫�࣬���ܲ�������');
return;
end
end
format short;123123456789101112131415161718192021222324252627282930313233343536373839404142version https://git-lfs.github.com/spec/v1oid sha256:4881942f8e1937a16c221635ac99110715868ac4b95b764ccaf60ffdda7281f2size 863function [r,m]=mulGXF1(F,x0,x1,eps)
format long;
if nargin==3
eps=1.0e-4;
end
x0 = transpose(x0);
x1 = transpose(x1);
n = length(x0);
fx = subs(F,findsym(F),x0);
fx1 = subs(F,findsym(F),x1);
h = x0 - x1;
J = zeros(n,n);
for i=1:n
xt = x1;
xt(i) = x0(i);
J(:,i) = (subs(F,findsym(F),xt)-fx1)/h(i);
end
r=x1-inv(J)*fx1;
m=1;
tol=1;
while tol>eps
x0 = x1;
x1 = r;
fx = subs(F,findsym(F),x0);
fx1 = subs(F,findsym(F),x1);
h = x0 - x1;
J = zeros(n,n);
for i=1:n
xt = x1;
xt(i) = x0(i);
J(:,i) = (subs(F,findsym(F),xt)-fx1)/h(i);
end
r=x1-inv(J)*fx1;
tol=norm(r-x1);
m=m+1;
if(m>100000) %������������
disp('��������̫�࣬���ܲ�������');
return;
end
end
format short;12312345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152version https://git-lfs.github.com/spec/v1oid sha256:75526b08c6e8dd80af8f9e546ea3fcd803b93ab38d70bf6f6ca80b239fb2f8absize 1203function [r,m]=mulGXF2(F,x0,x1,eps)
format long;
if nargin==3
eps=1.0e-4;
end
x0 = transpose(x0);
x1 = transpose(x1);
n = length(x0);
fx = subs(F,findsym(F),x0);
fx1 = subs(F,findsym(F),x1);
h = x0 - x1;
J = zeros(n,n);
xt = x1;
xt(1) = x0(1);
J(:,1) = (subs(F,findsym(F),xt)-subs(F,findsym(F),x1))/h(1);
for i=2:n
xt = x1;
xt(1:i) = x0(1:i);
xt_m = x1;
xt_m(1:i-1) = x0(1:i-1);
J(:,i) = (subs(F,findsym(F),xt)-subs(F,findsym(F),xt_m))/h(i);
end
r=x1-inv(J)*fx1;
m=1;
tol=1;
while tol>eps
x0 = x1;
x1 = r;
fx = subs(F,findsym(F),x0);
fx1 = subs(F,findsym(F),x1);
h = x0 - x1;
J = zeros(n,n);
xt = x1;
xt(1) = x0(1);
J(:,1) = (subs(F,findsym(F),xt)-subs(F,findsym(F),x1))/h(1);
for i=2:n
xt = x1;
xt(1:i) = x0(1:i);
xt_m = x1;
xt_m(1:i-1) = x0(1:i-1);
J(:,i) = (subs(F,findsym(F),xt)-subs(F,findsym(F),xt_m))/h(i);
end
r=x1-inv(J)*fx1;
tol=norm(r-x1);
m=m+1;
if(m>100000) %������������
disp('��������̫�࣬���ܲ�������');
return;
end
end
format short;123123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051version https://git-lfs.github.com/spec/v1oid sha256:876459b9a76bd610853487db71a8860077e7ff1c11d4c23a955b0ee94930050csize 1075function [r,m]=mulMix(F,x0,h,l,eps)
if nargin==4
eps=1.0e-4;
end
n = length(x0);
J = zeros(n,n);
Fx = subs(F,findsym(F),x0);
for i=1:n
x1 = x0;
x1(i) = x1(i)+h(i);
J(:,i) = (subs(F,findsym(F),x1)-Fx)/h(i);
end
D = diag(diag(J));
C = D - J;
inD = inv(D);
H = inD*C;
Hm = eye(n,n);
for i=1:l-1
Hm = Hm + power(H,i);
end
dr = Hm*inD*Fx;
r = transpose(x0)-dr;
m=1;
tol=1;
while tol>eps
x0=r;
Fx = subs(F,findsym(F),x0);
J = zeros(n,n);
for i=1:n
x1 = x0;
x1(i) = x1(i)+h(i);
J(:,i) = (subs(F,findsym(F),x1)-Fx)/h(i);
end
D = diag(diag(J));
C = D - J;
inD = inv(D);
H = inD*C;
Hm = eye(n,n);
for i=1:l-1
Hm = Hm + power(H,i);
end
dr = Hm*inD*Fx;
r = x0-dr; %���ĵ�����ʽ
tol=norm(r-x0);
m=m+1;
if(m>100000) %������������
disp('��������̫�࣬���ܲ�������');
return;
end
end123123456789101112131415161718192021222324version https://git-lfs.github.com/spec/v1oid sha256:480022f7b4ff8d61afde65df886e2962de765d4382adacf8d815bca1c72c3dd2size 579function [r,n]=mulNewton(F,x0,eps)
if nargin==2
eps=1.0e-4;
end
x0 = transpose(x0);
Fx = subs(F,findsym(F),x0);
var = findsym(F);
dF = Jacobian(F,var);
dFx = subs(dF,findsym(dF),x0);
r=x0-inv(dFx)*Fx;
n=1;
tol=1;
while tol>eps
x0=r;
Fx = subs(F,findsym(F),x0);
dFx = subs(dF,findsym(dF),x0);
r=x0-inv(dFx)*Fx; %���ĵ�����ʽ
tol=norm(r-x0);
n=n+1;
if(n>100000) %������������
disp('��������̫�࣬���ܲ�������');
return;
end
end1231234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253version https://git-lfs.github.com/spec/v1oid sha256:983de2a9ea443f1ed1ea573759c7f45f8d077a25c147a2321f96994fc114d084size 1168function [r,m]=mulNewtonSOR(F,x0,w,h,l,eps)
if nargin==5
eps=1.0e-4;
end
n = length(x0);
J = zeros(n,n);
Fx = subs(F,findsym(F),x0);
for i=1:n
x1 = x0;
x1(i) = x1(i)+h(i);
J(:,i) = (subs(F,findsym(F),x1)-Fx)/h(i);
end
D = diag(diag(J));
L = -tril(J-D);
U = -triu(J-D);
inD = inv(D-w*L);
H = inD*(D - w*D+w*L);;
Hm = eye(n,n);
for i=1:l-1
Hm = Hm + power(H,i);
end
dr = w*Hm*inD*Fx;
r = transpose(x0)-dr;
m=1;
tol=1;
while tol>eps
x0=r;
Fx = subs(F,findsym(F),x0);
J = zeros(n,n);
for i=1:n
x1 = x0;
x1(i) = x1(i)+h(i);
J(:,i) = (subs(F,findsym(F),x1)-Fx)/h(i);
end
D = diag(diag(J));
L = -tril(J-D);
U = -triu(J-D);
inD = inv(D-w*L);
H = inD*(D - w*D+w*L);;
Hm = eye(n,n);
for i=1:l-1
Hm = Hm + power(H,i);
end
dr = w*Hm*inD*Fx;
r = x0-dr; %���ĵ�����ʽ
tol=norm(r-x0);
m=m+1;
if(m>100000) %������������
disp('��������̫�࣬���ܲ�������');
return;
end
end123123456789101112131415161718192021222324252627282930313233343536version https://git-lfs.github.com/spec/v1oid sha256:b6aff25395cd1ff22c09f6fe71178ec431fb24fa62ea4e2d861151a99664c554size 781function [r,m]=mulModifNewton(F,x0,h,eps)
format long;
if nargin==3
eps=1.0e-8;
end
n = length(x0);
fx = subs(F,findsym(F),x0);
J = zeros(n,n);
for i=1:n
x1 = x0;
x1(i) = x1(i)+h(i);
J(:,i) = (subs(F,findsym(F),x1)-fx)/h(i);
end
r=transpose(x0)-inv(J)*fx;
m=1;
tol=1;
while tol>eps
xs=r;
fx = subs(F,findsym(F),xs);
J = zeros(n,n);
h = fx;
for i=1:n
x1 = xs;
x1(i) = x1(i)+h(i);
J(:,i) = (subs(F,findsym(F),x1)-fx)/h(i);
end
r=xs-inv(J)*fx; %���ĵ�����ʽ
tol=norm(r-xs);
m=m+1;
if(m>100000) %������������
disp('��������̫�࣬���ܲ�������');
return;
end
end
format short;123123456789101112131415161718192021222324252627282930313233343536373839404142version https://git-lfs.github.com/spec/v1oid sha256:ce89539a86d0249290fbff3422b69d9918c5a7be4cc3ee9e09b874b9872da2b3size 895function [r,m]=mulNumYT(F,x0,h,N,eps)
format long;
if nargin==4
eps=1.0e-8;
end
n = length(x0);
fx0 = subs(F,findsym(F),x0);
x0 = transpose(x0);
J = zeros(n,n);
for k=0:N-1
fx = subs(F,findsym(F),x0);
for i=1:n
x1 = x0;
x1(i) = x1(i)+h(i);
J(:,i) = (subs(F,findsym(F),x1)-fx)/h(i);
end
inJ = inv(J);
r=x0-inJ*(fx-(1-k/N)*fx0);
x0 = r;
end
m=1;
tol=1;
while tol>eps
xs=r;
fx = subs(F,findsym(F),xs);
J = zeros(n,n);
for i=1:n
x1 = xs;
x1(i) = x1(i)+h(i);
J(:,i) = (subs(F,findsym(F),x1)-fx)/h(i);
end
r=xs-inv(J)*fx; %���ĵ�����ʽ
tol=norm(r-xs);
m=m+1;
if(m>100000) %������������
disp('��������̫�࣬���ܲ�������');
return;
end
end
format short;12312345678910111213141516171819202122232425262728293031version https://git-lfs.github.com/spec/v1oid sha256:0e1c835f48256a286b26e56166908e7f1233b6916510e80c7c495b3caa6daaf2size 677function [r,n]=mulRank1(F,x0,A,eps)
if nargin==2
l = length(x0);
A=eye(l); %AȡΪ��λ��
eps=1.0e-4;
else
if nargin==3
eps=1.0e-4;
end
end
fx = subs(F,findsym(F),x0);
r=transpose(x0)-inv(A)*fx;
n=1;
tol=1;
while tol>eps
x0=r;
fx = subs(F,findsym(F),x0);
r=x0-inv(A)*fx;
y=r-x0;
fr = subs(F,findsym(F),r);
z = fr-fx;
A1=A+ fr *transpose(fr)/(transpose(fr)*y); %����A
A=A1;
n=n+1;
if(n>100000) %������������
disp('��������̫�࣬���ܲ�������');
return;
end
tol=norm(r-x0);
end1231234567891011121314151617181920212223242526272829version https://git-lfs.github.com/spec/v1oid sha256:05539173bce6cf7a7aa7307d1f044b80ed67f6c4ffaae8494aabf78fe7d56108size 600function [r,n]=mulSimNewton(F,x0,eps)
%�����Է����飺f
%��ʼ�⣺a
%��ľ��ȣ�eps
%��õ�һ��⣺r
%����������n
if nargin==2
eps=1.0e-6;
end
x0 = transpose(x0);
Fx = subs(F,findsym(F),x0);
dF = Jacobian(F);
c = subs(dF,findsym(dF),x0);
r=x0-inv(c)*Fx;
n=1;
tol=1;
while tol>eps
x0=r;
Fx = subs(F,findsym(F),x0);
r=x0-inv(c)*Fx; %���ĵ�����ʽ
tol=norm(r-x0);
n=n+1;
if(n>100000) %������������
disp('��������̫�࣬���ܲ�������');
return;
end
end123123456789101112131415161718192021222324version https://git-lfs.github.com/spec/v1oid sha256:9f5be3b9edfd3eeb1bd4c30ada5e30cddb418f5404450b0bd739ae7499240208size 516function [r,n]=mulStablePoint(F,x0,eps)
%�����Է����飺f
%��ʼ�⣺a
%��ľ��ȣ�eps
%��õ�һ��⣺r
%����������n
if nargin==2
eps=1.0e-6;
end
x0 = transpose(x0);
n=1;
tol=1;
while tol>eps
r= subs(F,findsym(F),x0); %������ʽ
tol=norm(r-x0); %ע�������������normΪ�����ŷ����·���
n=n+1;
x0=r;
if(n>100000) %������������
disp('��������̫�࣬���ܲ�������');
return;
end
end1231234567891011121314151617181920212223242526272829303132333435363738version https://git-lfs.github.com/spec/v1oid sha256:e79a20847c8e800699ce4bc03b03190f9a1c87a0bf7a9da72d6b6fc109660802size 732function [r,m]=mulVNewton(F,x0,A,eps)
%�����飺F
%������ij�ʼ�⣺x0
% ��ʼA����A
%��ľ��ȣ�eps
%��õ�һ��⣺r
%����������m
if nargin==2
A=eye(length(x0)); %AȡΪ��λ��
eps=1.0e-4;
else
if nargin==3
eps=1.0e-4;
end
end
x0 = transpose(x0);
Fx = subs(F, findsym(F),x0);
r=x0-A\Fx;
m=1;
tol=1;
while tol>eps
x0=r;
Fx = subs(F, findsym(F),x0);
r=x0-A\Fx;
y=r-x0;
Fr = subs(F, findsym(F),r);
z= Fr-Fx;
A1=A+(z-A*y)*transpose(y)/norm(y); %����A
A=A1;
m=m+1;
if(m>100000) %������������
disp('��������̫�࣬���ܲ�������');
return;
end
tol=norm(r-x0);
end12312345678910111213141516171819202122version https://git-lfs.github.com/spec/v1oid sha256:e1ee171f68b37d5709515fb96203cc3ae5d9a9b84a24f9f1ef26530febd3e84bsize 494function [x,L,U]=Crout(A,b)
N = size(A);
n = N(1);
L = zeros(n,n);
U = eye(n,n); %U�ĶԽ�Ԫ��Ϊ1
L(1:n,1) = A(1:n,1); %L�ĵ�һ��
U(1,1:n) = A(1,1:n)/L(1,1); %U�ĵ�һ��
for k=2:n
for i=k:n
L(i,k) = A(i,k)-L(i,1:(k-1))*U(1:(k-1),k);
%L�ĵ�k��
end
for j=(k+1):n
U(k,j) = (A(k,j)-L(k,1:(k-1))*U(1:(k-1),j))/L(k,k);
%U�ĵ�k��
end
end
y = SolveDownTriangle(L,b);
x = SolveUpTriangle(U,y); %��ⷽ��12312345678910111213141516171819202122version https://git-lfs.github.com/spec/v1oid sha256:9159b0c2d98ba9e32c268edcb4a073b1497f1a914475ceb6121ae5f37bf914e1size 496function [x,L,U]= Doolittle (A,b)
N = size(A);
n = N(1);
L = eye(n,n); %L�ĶԽ�Ԫ��Ϊ1
U = zeros(n,n);
U(1,1:n) = A(1,1:n); %U�ĵ�һ��
L(1:n,1) = A(1:n,1)/U(1,1); %L�ĵ�һ��
for k=2:n
for i=k:n
U(k,i) = A(k,i)-L(k,1:(k-1))*U(1:(k-1),i);
%U�ĵ�k��
end
for j=(k+1):n
L(j,k) = (A(j,k)-L(j,1:(k-1))*U(1:(k-1),k))/U(k,k);
%L�ĵ�k��
end
end
y = SolveDownTriangle(L,b);
x = SolveUpTriangle(U,y); %��ⷽ��123123456789101112131415161718192021222324252627282930313233343536version https://git-lfs.github.com/spec/v1oid sha256:2ed452b37af6f6757a255e0ad749a1abf5a77f9761276ebfdeffc3290e1376dcsize 758function [x,XA]= GaussJordanXQ (A,b)
N = size(A);
n = N(1);
index = 0;
pos = zeros(n,1);
B = A;
for i=1:n
me = max(abs(B(1:n,i))); %ѡȡ����Ԫ
for k=1:n
if(abs(A(k,i))==me)
index = k;
pos(i,1) = k; %��������Ԫ���ڵ��к�
break;
end
end
m = A(index,i);
for j=1:n
if(j ~= index)
l = A(j,i);
A(j,1:n)=A(j,1:n)-l*A(index,1:n)/m;
b(j)=b(j)-l*b(index)/m; %��Ԫ
end
end
B = A;
for k=1:n
if(pos(k,1)~=0)
B(pos(k,1),1:n)=0; %��������Ԫ��ͬһ��
end
end
end
XA = A;
for i=1:n
x(i,1)=b(pos(i,1))/A(pos(i,1),i); %���
end12312345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758version https://git-lfs.github.com/spec/v1oid sha256:3569838a6dca5d2e132048fe05f9af5b54cba2ff777a87dcaacee5e7e22549absize 1337function [x,XA]= GaussXQAllMain (A,b)
N = size(A);
n = N(1);
index_l = 0;
index_r = 0;
order = 1:n; %��¼δ֪��˳�������
for i=1:(n-1)
me = max(max(abs(A(i:n,i:n)))); %ѡȡȫ��Ԫ
for k=i:n
for r=i:n
if(abs(A(k,r))==me)
index_l = k;
index_r = r; %������Ԫ���ڵ��к���
k=n;
break;
end
end
end
temp = A(i,1:n);
A(i,1:n) = A(index_l,1:n);
A(index_l,1:n) = temp;
bb = b(index_l);
b(index_l)=b(i);
b(i) = bb; %��������
temp = A(1:n,i);
A(1:n,i) = A(1:n,index_r);
A(1:n,index_r) = temp; %��������
pos = order(i);
order(i) = order(index_r);
order(index_r) = pos; %���еĽ��������δ֪��˳��ı仯
for j=(i+1):n
if(A(i,i)==0)
disp('�Խ�Ԫ��Ϊ0��');
return;
end
l = A(j,i);
m = A(i,i);
A(j,1:n)=A(j,1:n)-l*A(i,1:n)/m;
b(j)=b(j)-l*b(i)/m;
end
end
x=SolveUpTriangle(A,b);
y=zeros(n,1);
for i=1:n
for j=1:n
if(order(j)==i)
y(i)=x(j);
end
end
end %�ָ�δ֪��ԭ����˳��
x=y;
XA = A;12312345678910111213141516171819version https://git-lfs.github.com/spec/v1oid sha256:6e757f389d170a651f5255378587fcc62b9eda62b3f2423ded70dc2aa39410cfsize 514function [x,XA]=GaussXQByOrder(A,b)
N = size(A);
n = N(1);
for i=1:(n-1)
for j=(i+1):n
if(A(i,i)==0)
disp('�Խ�Ԫ��Ϊ0��'); %��ֹ�Խ�Ԫ��Ϊ0
return;
end
l = A(j,i);
m = A(i,i);
A(j,1:n)=A(j,1:n)-l*A(i,1:n)/m; %��Ԫ����
b(j)=b(j)-l*b(i)/m;
end
end
x=SolveUpTriangle(A,b); %ͨ�õ���������ϵ���������Է�����ĺ���
XA = A; %��Ԫ���ϵ������12312345678910111213141516171819202122232425262728293031323334version https://git-lfs.github.com/spec/v1oid sha256:a1690206834461f11db33b579e43e4e3b770716e96e03c00aad12c7406d1136dsize 768function [x,XA]=GaussXQLineMain(A,b)
N = size(A);
n = N(1);
index = 0;
for i=1:(n-1)
me = max(abs(A(1:n,i))); %ѡȡ����Ԫ
for k=i:n
if(abs(A(k,i))==me)
index = k; %��������Ԫ���ڵ���
break;
end
end
temp = A(i,1:n);
A(i,1:n) = A(index,1:n);
A(index,1:n) = temp;
bb = b(index);
b(index)=b(i);
b(i) = bb; %��������
for j=(i+1):n
if(A(i,i)==0)
disp('�Խ�Ԫ��Ϊ0��');
return;
end
l = A(j,i);
m = A(i,i);
A(j,1:n)=A(j,1:n)-l*A(i,1:n)/m;
b(j)=b(j)-l*b(i)/m; %��Ԫ
end
end
x=SolveUpTriangle(A,b);
XA = A;1231234567891011121314151617181920version https://git-lfs.github.com/spec/v1oid sha256:937ac9540e0f2851547ec9ac81beb1c132c4603e6ce76d94cd064487e570e42fsize 441function [x,IA]=InvAddSide(A,b)
IA = Inv(A);
x = IA*b;
%�������ĵݹ麯��
function invA=Inv(A)
N = size(A);
n = N(1);
if(n == 1)
invA = 1/A(n,n); %�ݹ����ֹ����
else
u = A(1:(n-1),n);
v = A(n,1:(n-1));
iA = Inv(A(1:(n-1),1:(n-1))); %�ݹ鹫ʽ
An = A(n,n) - v*iA*u;
r = -iA*u/An;
p = iA + iA*u*v*iA/An;
q = -v*iA/An;
invA = [p r;q 1/An]; %�����
end1231234567891011121314151617version https://git-lfs.github.com/spec/v1oid sha256:108ae627b635f17c303e70c976d4201e6345e7d3db09e4e200f91ff49d971818size 424function [x,L]= SymPos1 (A,b)
N = size(A);
n = N(1);
L(1,1) = sqrt(A(1,1));
L(2:n,1) = A(2:n,1)/L(1,1); %L�ĵ�һ��
for k=2:n
L(k,k) = sqrt(A(k,k)-L(k,1:(k-1))*transpose(L(k,1:(k-1))));
%L�ĶԽ�Ԫ��
for i=(k+1):n
L(i,k) = (A(i,k)-L(i,1:(k-1))*transpose(L(k,1:(k-1))))/L(k,k);
%L�ĵ�k��
end
end
y = SolveDownTriangle(L,b);
x = SolveUpTriangle(transpose(L),y); %��ⷽ��1231234567891011121314151617181920version https://git-lfs.github.com/spec/v1oid sha256:c39dab4c7895c62b88f368586183083855660e479321c284150e7b0f9eadf949size 481function [x,L,D]= SymPos2 (A,b)
N = size(A);
n = N(1);
L = eye(n,n); %L�ĶԽ�Ԫ��Ϊ1
d = zeros(n,1);
for k=1:n
d(k,1) = A(k,k)-L(k,1:(k-1)).*L(k,1:(k-1))*d(1:(k-1),1);
%D�ĵ�k���Խ�Ԫ��
for i=(k+1):n
L(i,k) = (A(i,k)-L(i,1:(k-1)).*L(k,1:(k-1))*d(1:(k-1),1))/d(k,1);
%L�ĵ�k��
end
end
D = diag(d);
y = SolveDownTriangle(L,b); %���y
for i=1:n
y(i,1)=y(i,1)/d(i,1);
end
x = SolveUpTriangle(transpose(L),y); %���x123123456789101112131415161718192021222324version https://git-lfs.github.com/spec/v1oid sha256:eadee427b92c07fd626ef602d5e7af73130be40d9d19731f3a734fb69b52cc85size 583function [x,L,D]= SymPos3 (A,b)
N = size(A);
n = N(1);
L = eye(n,n); %L�ĶԽ�Ԫ��Ϊ1
d = zeros(n,1);
AA = zeros(n,n); %���������
for k=1:n
d(k,1) = A(k,k)-AA(k,1:(k-1))*transpose(L(k,1:(k-1)));
%D�ĵ�k���Խ�Ԫ��
for i=(k+1):n
AA(i,k) = A(i,k)-AA(i,1:(k-1))*transpose(L(k,1:(k-1)));
%AA�ĵ�k��
L(i,k) = AA(i,k)/d(k,1);
%L�ĵ�k��
end
end
D = diag(d);
y = SolveDownTriangle(L,b); %���y
for i=1:n
y(i,1)=y(i,1)/d(i,1);
end
x = SolveUpTriangle(transpose(L),y); %���x1231234567891011121314151617181920212223242526version https://git-lfs.github.com/spec/v1oid sha256:3609d0cb45ec886e23fcdce55556b216415977a07c89ab5e451ca65fa28a168asize 580function [x,IA]= Yesf(A,b)
N = size(A);
n = N(1);
A1 = A -eye(n,n);
A2 = zeros(n,n);
A3 = zeros(n,n);
for m=1:n
for i=1:n
for j=1:n
if(i ~= m)
A2(i,j) = A1(i,j);
else
if(j == m)
A2(i,j) = 1;
else
A2(i,j) = 0;
end
end
end
end %��һ������
A3 = A2 - A2(1:n,m)*A1(m,1:n)/(1+A1(m,m)); %�ڶ�������
A1 = A3;
end
IA=A3;
x = A3*b; %��ⷽ��1231234567891011121314151617181920212223242526272829version https://git-lfs.github.com/spec/v1oid sha256:6e80a4c4ca02953ed952d7134e1da8110c6e3e03f61511197c0b17d26ee802dcsize 468function [x,n]=conjgrad(A,b,x0)if(nargin == 3) eps = 1.0e-6;end
r1 = b-A*x0;p1 = r1;d = dot(r1,r1)/dot(p1,A*p1);x = x0+d*p1;r2 = r1-d*A*p1;f = dot(r2,r2)/dot(r1,r1);p2 = r2+f*p1;n = 1;
for(i=1:(rank(A)-1)) x0 = x; p1 = p2; r1 = r2; d = dot(r1,r1)/dot(p1,A*p1); x = x0+d*p1; r2 = r1-d*A*p1; f = dot(r2,r2)/dot(r1,r1); p2 = r2+f*p1; n = n + 1;end
d = dot(r2,r2)/dot(p2,A*p2);x = x+d*p2;n = n + 1;1231234567891011121314151617181920212223242526272829version https://git-lfs.github.com/spec/v1oid sha256:95179bef8c4277d430e9d7347579dee500e11204e89ac6db66a353ba113e2c5esize 495function x=followup(A,b)n = rank(A);for(i=1:n) if(A(i,i)==0) disp('Error: �Խ���Ԫ��Ϊ0��'); return; endend;
d = ones(n,1);a = ones(n-1,1);c = ones(n-1);
for(i=1:n-1) a(i,1)=A(i+1,i); c(i,1)=A(i,i+1); d(i,1)=A(i,i);endd(n,1) = A(n,n);
for(i=2:n) d(i,1)=d(i,1) - (a(i-1,1)/d(i-1,1))*c(i-1,1); b(i,1)=b(i,1) - (a(i-1,1)/d(i-1,1))*b(i-1,1);endx(n,1) = b(n,1)/d(n,1);
for(i=(n-1):-1:1) x(i,1) = (b(i,1)-c(i,1)*x(i+1,1))/d(i,1);end 1231234567891011121314151617version https://git-lfs.github.com/spec/v1oid sha256:ac71adc9a4744b6240defb34457fa0632be6ef10494252bd59c627e615576cd0size 490function [x,Q,R]=qrxq(A,b)
N = size(A);
n = N(1);
B = A; %����ϵ������
A(1:n,1)=A(1:n,1)/norm(A(1:n,1)); %��A�ĵ�һ�����滯
for i=2:n
for j=1:(i-1)
A(1:n,i)= A(1:n,i)-dot(A(1:n,i),A(1:n,j))*A(1:n,j);
%ʹA�ĵ�i����ǰ�����е�������
end
A(1:n,i)=A(1:n,i)/norm(A(1:n,i));
%��A�ĵ�i�����滯
end
Q = A; %�ֽ��������������
R = transpose(Q)*B;
x=SolveUpTriangle(R,transpose(Q)*b); %��ⷽ��123123456789101112131415161718192021222324252627282930313233343536373839404142version https://git-lfs.github.com/spec/v1oid sha256:64fee34195fcd22adabaefb9cfe61ef4b26aa9b8923fbe0644383d62bfdc148csize 846function [x,N]= BGS(A,b,x0,d,eps,M)
if nargin==4
eps= 1.0e-6;
M = 10000;
elseif nargin<4
error
return
elseif nargin ==5
M = 10000;
end
NS = size(A);
n = NS(1,1);
bnum = length(d);
bs = ones(bnum,1);
for i=1:(bnum-1)
bs(i+1,1)=sum(d(1:i))+1;
%��öԽ�����ÿ���ֿ����Ԫ����������ʼֵ
end
DB = zeros(n,n);
for i=1:bnum
endb = bs(i,1)+d(i,1)-1;
DB(bs(i,1):endb,bs(i,1):endb)=A(bs(i,1):endb,bs(i,1):endb);
%��A�ĶԽǷֿ����
end
LB = -tril(A-DB); %��A�������Ƿֿ���
UB = -triu(A-DB); %��A�������Ƿֿ���
N = 0;
tol = 1;
while tol>=eps
invDL = inv(DB-LB);
x = invDL*UB*x0+invDL*b; %�������ʽ
N = N+1;
tol = norm(x-x0);
x0 = x;
if(N>=M)
disp('Warning: ��������̫�࣬���ܲ�������');
return;
end
end123123456789101112131415161718192021222324252627282930313233343536373839404142434445464748version https://git-lfs.github.com/spec/v1oid sha256:71572122decd61b1d760d0a66303eb82230ec8d1b82db5131c17ed8fc99f6711size 1092function [x,N]= BJ(A,b,x0,d,eps,M)
if nargin==4
eps= 1.0e-6;
M = 10000;
elseif nargin<4
error
return
elseif nargin ==5
M = 10000; %������Ĭ��ֵ
end
NS = size(A);
n = NS(1,1);
if(sum(d) ~= n)
disp('�ֿ����');
return;
end
bnum = length(d);
bs = ones(bnum,1);
for i=1:(bnum-1)
bs(i+1,1)=sum(d(1:i))+1;
%��öԽ�����ÿ���ֿ����Ԫ����������ʼֵ
end
DB = zeros(n,n);
for i=1:bnum
endb = bs(i,1)+d(i,1)-1;
DB(bs(i,1):endb,bs(i,1):endb)=A(bs(i,1):endb,bs(i,1):endb);
%��A�ĶԽǷֿ����
end
for i=1:bnum
endb = bs(i,1)+d(i,1)-1;
invDB(bs(i,1):endb,bs(i,1):endb)=inv(DB(bs(i,1):endb,bs(i,1):endb));
%��A�ĶԽǷֿ����������
end
N = 0;
tol = 1;
while tol>=eps
x = invDB*(DB-A)*x0+invDB*b; %����LB+DB=DB-A
N = N+1; %��������
tol = norm(x-x0); %ǰ������������������
x0 = x;
if(N>=M)
disp('Warning: ��������̫�࣬���ܲ�������');
return;
end
end12312345678910111213141516171819202122232425262728293031323334353637383940414243version https://git-lfs.github.com/spec/v1oid sha256:4feb9418201735fbe25fa355c6653db848467d0e449b4636f34d1594b91ebea7size 884function [x,N]= BSOR(A,b,x0,d,w,eps,M)
if nargin==5
eps= 1.0e-6;
M = 10000;
elseif nargin<5
error
return
elseif nargin ==6
M = 10000; %����Ĭ��ֵ
end
NS = size(A);
n = NS(1,1);
bnum = length(d);
bs = ones(bnum,1);
for i=1:(bnum-1)
bs(i+1,1)=sum(d(1:i))+1;
%��öԽ�����ÿ���ֿ����Ԫ����������ʼֵ
end
DB = zeros(n,n);
for i=1:bnum
endb = bs(i,1)+d(i,1)-1;
DB(bs(i,1):endb,bs(i,1):endb)=A(bs(i,1):endb,bs(i,1):endb);
%��A�ĶԽǾ���
end
LB = -tril(A-DB); %��A����������
UB = -triu(A-DB); %��A����������
N = 0;
tol = 1;
iw = 1-w;
while tol>=eps
invDL = inv(DB-w*LB);
x = invDL*(iw*DB+w*UB)*x0+w*invDL*b; %�������ʽ
N = N+1;
tol = norm(x-x0);
x0 = x;
if(N>=M)
disp('Warning: ��������̫�࣬���ܲ�������');
return;
end
end12312345678910111213141516171819202122232425262728version https://git-lfs.github.com/spec/v1oid sha256:b0e831c9cb94059ca645536efbe2e9db7074e539608d556ae3f0963a85b00517size 521function [x,n]=JOR(A,b,x0,w,eps,M)
if nargin==4
eps= 1.0e-6;
M = 10000;
elseif nargin ==5
M = 10000;
end
if(w<=0 || w>=2) %��������Ҫ��
error;
return;
end
D=diag(diag(A)); %��A�ĶԽǾ���
B=w*inv(D);
%��������
x=x0;
n=0; %��������
tol=1;
%��������
while tol>=eps
x=x0-B*(A*x0-b);
n = n+1;
tol = norm(x-x0);
x0 = x;
if(n>=M)
disp('Warning: ��������̫�࣬���ܲ�������');
return;
end
end123123456789101112131415161718192021222324252627282930313233version https://git-lfs.github.com/spec/v1oid sha256:8611f4259157037c7f749a7ab708f140b166e1b63a8e92e221c698ab00bb5bb4size 579function [x,n]=SOR(A,b,x0,w,eps,M)
if nargin==4
eps= 1.0e-6;
M = 200;
elseif nargin<4
error
return
elseif nargin ==5
M = 200;
end
if(w<=0 || w>=2)
error;
return;
end
D=diag(diag(A)); %��A�ĶԽǾ���
L=-tril(A,-1); %��A����������
U=-triu(A,1); %��A����������
B=inv(D-L*w)*((1-w)*D+w*U);
f=w*inv((D-L*w))*b;
x=B*x0+f;
n=1; %��������
while norm(x-x0)>=eps
x0=x;
x =B*x0+f;
n=n+1;
if(n>=M)
disp('Warning: ��������̫�࣬���ܲ�������');
return;
end
end1231234567891011121314151617181920212223242526272829303132333435363738version https://git-lfs.github.com/spec/v1oid sha256:7f8b3499d504501dc700030bd8f09db7c72de2aa04a755f7cf15266f61832fc5size 679function [x,n]=SSOR(A,b,x0,w,eps,M)
if nargin==4
eps= 1.0e-6;
M = 200;
elseif nargin<4
error
return
elseif nargin ==5
M = 200;
end
if(w<=0 || w>=2)
error;
return;
end
D=diag(diag(A)); %��A�ĶԽǾ���
L=-tril(A,-1); %��A����������
U=-triu(A,1); %��A����������
B1=inv(D-L*w)*((1-w)*D+w*U);
B2=inv(D-U*w)*((1-w)*D+w*L);
f1=w*inv((D-L*w))*b;
f2=w*inv((D-U*w))*b;
x12=B1*x0+f1;
x =B2*x12+f2;
n=1; %��������
while norm(x-x0)>=eps
x0=x;
x12=B1*x0+f1;
x =B2*x12+f2;
n=n+1;
if(n>=M)
disp('Warning: ��������̫�࣬���ܲ�������');
return;
end
end123123456789101112131415161718version https://git-lfs.github.com/spec/v1oid sha256:4027a6c64f8336bf44abf543dcf015d59ec228e80ead825ef7035574a85bf938size 447function [x,n]= conjgrad (A,b,x0)
r1 = b-A*x0;
p = r1;
n = 0;
for i=1:rank(A) %���¹��̿ɲο��㷨����
if(dot(p,A*p) < 1.0e-50) %ѭ����������
break;
end
alpha = dot(r1,r1)/dot(p,A*p);
x = x0+ alpha*p;
r2 = r1- alpha*A*p;
if(r2 < 1.0e-50) %ѭ����������
break;
end
belta = dot(r2,r2)/dot(r1,r1);
p = r2+belta*p;
n = n + 1;
end12312345678910111213141516171819202122version https://git-lfs.github.com/spec/v1oid sha256:095d0550c82d19d893650f416eba59b4ce9da6a7490fc51c63d61fc1a08f9366size 537function [x,n]=crs(A,b,x0,w,eps,M)
if(nargin == 4)
eps = 1.0e-6; %eps��ʾ��������
M = 10000; %M��ʾ��������������ֵ
elseif(nargin == 5)
M = 10000;
end
I =eye(size(A));
n=0;
x=x0;
tol=1;
%��������
while (tol>eps)
x = (I-w*A)*x0+w*b;
n = n + 1; %nΪ���������ʱ�ĵ�������
tol = norm(x-x0);
x0 = x;
if(n>=M)
disp('Warning:��������̫�࣬���ܲ�������');
return;
end
end12312345678910111213141516version https://git-lfs.github.com/spec/v1oid sha256:a0632d5b1a9d817060e323277f1186e5488bad1c6e439f664369989a49c7d7b2size 289function [x,n]= fastdown(A,b,x0,eps)
if(nargin == 3)
eps = 1.0e-6;
end
x=x0;
n=0;
tol=1;
while(tol>eps) %���¹��̿ɲο��㷨����
r = b-A*x0;
d = dot(r,r)/dot(A*r,r);
x = x0+d*r;
tol = norm(x-x0);
x0 = x;
n = n + 1;
end1231234567891011121314151617181920212223242526version https://git-lfs.github.com/spec/v1oid sha256:dd23488f2c07a3766c95313f081c873b885e3827ecf650e26dff8aa43f891996size 510function [x,n]=gauseidel(A,b,x0,eps,M)
if nargin==3
eps= 1.0e-6;
M = 200;
elseif nargin == 4
M = 200;
elseif nargin<3
error
return;
end
D=diag(diag(A)); %��A�ĶԽǾ���
L=-tril(A,-1); %��A����������
U=-triu(A,1); %��A����������
G=(D-L)\U;
f=(D-L)\b;
x=G*x0+f;
n=1; %��������
while norm(x-x0)>=eps
x0=x;
x=G*x0+f;
n=n+1;
if(n>=M)
disp('Warning: ��������̫�࣬���ܲ�������');
return;
end
end12312345678910111213141516171819202122version https://git-lfs.github.com/spec/v1oid sha256:c39ec429c4a9f6828826513374a42a1621aa50d582b6b4cb797da83b4b5a22b9size 624function [x,n]=grs(A,b,x0,W,eps,M)
if(nargin == 4)
eps = 1.0e-6; %eps��ʾ��������
M = 10000; %M��ʾ��������������ֵ
elseif(nargin == 5)
M = 10000;
end
I =eye(size(A));
n=0;
x=x0;
tol=1; %ǰ�����ε���������
%��������
while (tol>eps)
x = (I-W*A)*x0+W*b; %������ʽ
n = n + 1; %nΪ���������ʱ�ĵ�������
tol = norm(x-x0);
x0 = x;
if(n>=M)
disp('Warning:��������̫�࣬���ܲ�������');
return;
end
end123123456789101112131415161718192021222324252627282930version https://git-lfs.github.com/spec/v1oid sha256:7dab33b03319bbd2f2abd296997b347c19e5e888f43e54227b777e30506686edsize 521function [x,n]=jacobi(A,b,x0,eps,varargin)
if nargin==3
eps= 1.0e-6;
M = 200;
elseif nargin<3
error
return
elseif nargin ==5
M = varargin{1};
end
D=diag(diag(A)); %��A�ĶԽǾ���
L=-tril(A,-1); %��A����������
U=-triu(A,1); %��A����������
B=D\(L+U);
f=D\b;
x=B*x0+f;
n=1; %��������
while norm(x-x0)>=eps
x0=x;
x=B*x0+f;
n=n+1;
if(n>=M)
disp('Warning: ��������̫�࣬���ܲ�������');
return;
end
end
1231234567891011121314151617181920212223version https://git-lfs.github.com/spec/v1oid sha256:87ef5e4b7893dea22d2bcba71be8c92ad029a3e7609dabbd3edcace909666488size 458function [x,n]= preconjgrad (A,b,x0,M,eps)
if nargin == 4
eps = 1.0e-6;
end
r1 = b-A*x0;
iM = inv(M);
z1 = iM*r1;
p = z1;
n = 0;
tol= 1;
while tol>=eps
alpha = dot(r1,z1)/dot(p,A*p);
x = x0 + alpha*p;
r2 = r1 - alpha*A*p;
z2 = iM*r2;
belta = dot(r2,z2)/dot(r1,z1);
p = z2+belta*p;
n = n + 1;
tol = norm(x-x0);
x0 = x; %���µ���ֵ
r1 = r2;
z1 = z2;
end12312345678910111213141516171819202122version https://git-lfs.github.com/spec/v1oid sha256:a3fefdc1345622e864a4ceb33e08ace242893dcd9f5543d8c35cade10623d0afsize 348function [x,n]=richason(A,b,x0,eps,M)
if(nargin == 3)
eps = 1.0e-6;
M = 200;
elseif(nargin == 4)
M = 200;
end
I =eye(size(A));
x1=x0;
x=(I-A)*x0+b;
n=1;
while(norm(x-x1)>eps)
x1=x;
x=(I-A)*x1+b;
n = n + 1;
if(n>=M)
disp('Warning: ��������̫�࣬�����˳���');
return;
end
endmatlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/DiffParam1.m+27-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/DiffParam2.m+36-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/SOR.m+40-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulBFS.m+32-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulConj.m+53-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulDFP.m+31-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulDNewton.m+35-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulDamp.m+60-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulDiscNewton.m+35-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulFastDown.m+30-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulGSND.m+29-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulGXF1.m+42-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulGXF2.m+52-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulMix.m+51-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulNewton.m+24-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulNewtonSOR.m+53-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulNewtonStev.m+36-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulNumYT.m+42-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulRank1.m+31-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulSimNewton.m+29-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulStablePoint.m+24-3
matlab数学建模算法/MATLAB语言常用算法程序集/第10章 非线性方程组求解/mulVNewton.m+38-3
matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/Crout.m+22-3
matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/Doolittle.m+22-3
matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/GaussJordanXQ.m+36-3
matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/GaussXQAllMain.m+58-3
matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/GaussXQByOrder.m+19-3
matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/GaussXQLineMain.m+34-3
matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/InvAddSide.m+20-3
matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/SymPos1.m+17-3
matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/SymPos2.m+20-3
matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/SymPos3.m+24-3
matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/Yesf.m+26-3
matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/conjgrad.m+29-3
matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/followup.m+29-3
matlab数学建模算法/MATLAB语言常用算法程序集/第11章 解线性方程组的直接法/qrxq.m+17-3
matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/BGS.m+42-3
matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/BJ.m+48-3
matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/BSOR.m+43-3
matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/JOR.m+28-3
matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/SOR.m+33-3
matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/SSOR.m+38-3
matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/conjgrad.m+18-3
matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/crs.m+22-3
matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/fastdown.m+16-3
matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/gauseidel.m+26-3
matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/grs.m+22-3
matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/jacobi.m+30-3
matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/preconjgrad.m+23-3
matlab数学建模算法/MATLAB语言常用算法程序集/第12章 解线性方程组的迭代法/richason.m+22-3