西安交大计算方法b大作业

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

1B:2015122221.0142118184858616nnSnnnn(1)11(2)30m=input('m=');s0=1;s1=0;s2=0;n=0;%whiles0=0.5*10^-(m-1)s0=4/(16^n*(8*n+1))-2/(16^n*(8*n+4))-1/(16^n*(8*n+5))-1/(16^n*(8*n+6));n=n+1;end%fork=n-1:-1:0a1=4/(16^k*(8*k+1));a2=2/(16^k*(8*k+4));a3=1/(16^k*(8*k+5));a4=1/(16^k*(8*k+6));s1=a1+s1;s2=a4+a3+a2+s2;endS=vpa(s1-s2,m)31113021.112.3041.20(:)01234569.018.967.967.978.029.0510.137891011121311.1812.2613.2813.3212.6111.2910.22141516171819209.157.907.958.869.8110.8010.93(1)(2)20P1102020191'2'2000l=1+(f())1+(f())kkkxdxxdxclear;clc;x=0:20;y=[9.018.967.967.978.029.0510.1311.1812.2613.2813.3212.6111.2910.229.157.907.958.869.8110.8010.93];d=y;plot(x,y,'k.','markersize',15)holdon%%%fork=1:2fori=21:-1:(k+1)d(i)=(d(i)-d(i-1))/(x(i)-x(i-k));endend%%%dfori=2:205d(i)=6*d(i+1);endd(1)=0;d(21)=0;%%%a=0.5*ones(1,21);b=2*ones(1,21);c=0.5*ones(1,21);a(1)=0;c(21)=0;u=ones(1,21);u(1)=b(1);r=c;yy(1)=d(1);%%%fork=2:21l(k)=a(k)/u(k-1);u(k)=b(k)-l(k)*r(k-1);yy(k)=d(k)-l(k)*yy(k-1);end%%%m(21)=yy(21)/u(21);fork=20:-1:1m(k)=(yy(k)-r(k)*m(k+1))/u(k);end%%%k=1;nn=100;xx=linspace(0,20,nn);l=0;forj=1:nnfori=2:20ifxx(j)=x(i)k=i;break;elsek=i+1;endendh=1;xbar=x(k)-xx(j);xmao=xx(j)-x(k-1);s(j)=(m(k-1)*xbar^3/6+m(k)*xmao^3/6+(y(k-1)-m(k-1)*h^2/6)*xbar+(y(k)-m(k)*h^2/6)*xmao)/h;6sp(j)=-m(k-1)*(x(k)-xx(j))^2/(2*h)+m(k)*(xx(j)-x(k-1))^2/(2*h)+(y(k)-y(k-1))/h-(m(k)-m(k-1))*h/6;l(j+1)=(1+sp(j)^2)^0.5*(20/nn)+l(j);%end%%%plot(xx,s,'r-','linewidth',1.5)disp(['1a',num2str(l(nn+1)),'?])2-12-22-12-173.;,012345678910111215141414141516182020232528131415161718192021222324313431292725242220181716MiP1231.1[Qk]1.2[Gk-1Gk]2.[]3.[]clear;clc;x=0:24;y=[15141414141516182020232528313431292725242220181716];m=length(x);n=input('');plot(x,y,'k.',x,y,'-')grid;holdon;n=n+1;G=zeros(m,n+1);G(:,n+1)=y';c=zeros(1,n);%cq=0;f=0;b=zeros(1,m);%b%%%G8forj=1:nfori=1:mG(i,j)=x(1,i)^(j-1);endend%%%Qkfork=1:nfori=k:mc(k)=G(i,k)^2+c(k);endc(k)=-sign(G(k,k))*(c(k)^0.5);w(k)=G(k,k)-c(k);%wforj=k+1:mw(j)=G(j,k);endb(k)=c(k)*w(k);%%%Gk-1GkG(k,k)=c(k);forj=k+1:n+1q=0;fori=k:mq=w(i)*G(i,j)+q;ends=q/b(k);fori=k:mG(i,j)=s*w(i)+G(i,j);endendend%%%Rx=h1a(n)=G(n,n+1)/G(n,n);fori=n-1:(-1):1forj=i+1:nf=G(i,j)*a(j)+f;enda(i)=(G(i,n+1)-f)/G(i,i);%aif=0;enda%%%p=zeros(1,m);forj=1:mfori=1:np(j)=p(j)+a(i)*x(j)^(i-1);endend9plot(x,p,'r*',x,p,'-');E2=0;%E2%%%fori=n+1:mE2=G(i,n+1)^2+E2;endE2=E2^0.5;disp('');disp(E2);t=0;fori=1:mt=t+p(i);endt=t/m;%%%disp(['',num2str(t),''])3-1103-23-3113-43-13-4124.52645200xx410,52f(x)=6x-45x+20,kk+1k'kf(x)x=x-f(x),.:functiony=f2(x)y=6*x.^5-45*x.^2+20;%functiony=f3(x)y=30*x^4-90*x;%i=-5:0.1:5;y=f2(i);plot(i,y)holdonplot(i,0,'-')%%%Newtonx1=input('');e=10^(-4);%Nmax=1000;%forn=1:Nmaxf0=f2(x1);ifabs(f2(x1))efprintf('f(x)');x=x1;breakelseF0=f3(x1);x=x1-f0/F0;ifabs(x-x1)ebreakelsex1=x;endendend13fprintf('x=%2f',x):4-14-24-14-24-2-0.6545420.6811741.870799145.12:,,,1.2.(2)clear;clc;%%[f,p]=uigetfile('*.dat','');%num=5;%name=strcat(p,f);file=fopen(name,'r');head=fread(file,num,'uint');%id=dec2hex(head(1));%fprintf('');idver=dec2hex(head(2));%fprintf('');vern=head(3);%fprintf('A');nq=head(4);%fprintf('A');15qp=head(5);%fprintf('A');pdist=4*num;fseek(file,dist,'bof');%[A,count]=fread(file,inf,'float');%fclose(file);%%%ifver=='102',a=zeros(n,n);fori=1:n,forj=1:n,a(i,j)=A((i-1)*n+j);%a(i,j)endendb=zeros(n,1);fori=1:n,b(i)=A(n*n+i);endfork=1:n-1,%m=k;fori=k+1:n,%ifabs(a(m,k))abs(a(i,k))m=i;endendifa(m,k)==0%disp('')returnendforj=1:n,%t=a(k,j);a(k,j)=a(m,j);a(m,j)=t;t=b(k);b(k)=b(m);b(m)=t;endfori=k+1:n,%l(i,k)a(i,k)a(i,k)=a(i,k)/a(k,k);forj=k+1:na(i,j)=a(i,j)-a(i,k)*a(k,j);end16b(i)=b(i)-a(i,k)*b(k);endendx=zeros(n,1);%x(n)=b(n)/a(n,n);fork=n-1:-1:1,x(k)=(b(k)-sum(a(k,k+1:n)*x(k+1:n)))/a(k,k);endend%%ifver=='202',%m=p+q+1;a=zeros(n,m);fori=1:1:nforj=1:1:ma(i,j)=A((i-1)*m+j);endendb=zeros(n,1);fori=1:1:nb(i)=A(n*m+i);%b(i)endfork=1:1:(n-1)%ifa(k,(p+1))==0disp('');break;endst1=n;if(k+p)nst1=k+p;endfori=(k+1):1:st1a(i,(k+p-i+1))=a(i,(k+p-i+1))/a(k,(p+1));forj=(k+1):1:(k+q)a(i,j+p-i+1)=a(i,j+p-i+1)-a(i,k+p-i+1)*a(k,j+p-k+1);endb(i)=b(i)-a(i,k+p-i+1)*b(k);endendx=zeros(n,1);%x(n)=b(n)/a(n,p+1);sum=0;fork=(n-1):-1:1sum=b(k);17st2=n;if(k+q)nst2=k+q;endforj=(k+1):1:st2sum=sum-a(k,j+p-k+1)*x(j);endx(k)=sum/a(k,p+1);sum=0;endenddisp('')%disp(x)dat51id=F1E1D1A0ver=102An=15Aq=3Ap=31.00001.00001.00001.00001.00001.00001.00001.00001.00001.00001.00001.00001.00001.00001.0000dat52id=F1E1D1A0ver=202An=20Aq=5Ap=5181.00001.00001.00001.00001.00001.00001.00001.00001.00001.00001.00001.00001.00001.00001.00001.00001.00001.00001.00001.0000dat53id=F1E1D1A0ver=102An=2160Aq=5Ap=55-15-1dat53dat53id=F1E1D1A0ver=202An=43240A19q=4Ap=45-25-2dat54

1 / 19
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功