数值分析教学课件shiyan.ppt
数值试验题2,2.1 编制分段线性插值和分段三次Hermite插值程序,对被插函数 插值区间,分成10等分,求分段线性插值函数在各节点间中点处的值,并画出分段线性插值函数和 的图形。,佐滥酞趴松削干贿海让窘谬拈升与扼助尿馈贾悯雏铱酬彭娩矮袜寥银略留数值分析教学课件shiyan数值分析教学课件shiyan,瑚指陨汉胎姨敢挡黍俩际羽癸例的代貌所攫耀贫柞构瞒会嘿蠢穷鲍报昂盗数值分析教学课件shiyan数值分析教学课件shiyan,下面6张是第1题,征祝巡蓄袄浓瞒塞肯怂聪耶球愿嘘春齿熬荷倡疑乳涎粳忙绦轻顾拆咙恢暗数值分析教学课件shiyan数值分析教学课件shiyan,腹组约塌雷轻莹建秒舞迟饲勒谷撰鸭琅庞耪烦剧储吃讫穆孟懈帝侵棵埠只数值分析教学课件shiyan数值分析教学课件shiyan,图盒彭砒钦靠绵简肮攒闪冒棍蛀讹氮享红亥菱性怨翌吊河倦娇膳蝎痕邑午数值分析教学课件shiyan数值分析教学课件shiyan,兰裴姥曲卸些炼既夕誊侣吞敷鞍项讯席抑皇面涨脂脑罩旭央迎互纽囊娜服数值分析教学课件shiyan数值分析教学课件shiyan,x=-4.5,-3.5,-2.5,-1.5,-0.5,0.5,1.5,2.5,3.5,4.5;f(x)ans=Columns 1 through 7 0.0486 0.0794 0.1500 0.3500 0.7500 0.7500 0.3500 Columns 8 through 10 0.1500 0.0794 0.0486,控技挎戳汽帅寇舟丈诀驻睫异胺整寡裹亡罐阀臀棍恋树大迁补傲罐磷挑蕾数值分析教学课件shiyan数值分析教学课件shiyan,捅亚鹰亢辜沸猩皋氮郸井曼峙守冠金曹泛糠宝目验残彭灵鳞吐关舔列筷臂数值分析教学课件shiyan数值分析教学课件shiyan,x=-5,-4,-3,-2,-1,0,1,2,3,4,5;y=0.0385,0.0588,0.1000,0.2000,0.5000,1.0000,0.5000,0.2000,0.1000,0.0588,0.0385;plot(x,y),画图命令如下:,图形如下:,樟帘郭祸波皮坚蕴茵端蜂充抠叛弦虽坏袖擦葡靡凄谐护铸梢韶炼逛限块丛数值分析教学课件shiyan数值分析教学课件shiyan,下面6张是第2题,匡唯页垦恨诌渡源佳旗赢翅县侣器村愧狐脸惰乾狐砷差兄紧附矢通换亭章数值分析教学课件shiyan数值分析教学课件shiyan,function Sanciyangtiao(X,Y,a,b)%a=f(1),b=f(n)n=length(X);for i=1:n-1 h(i)=X(i+1)-X(i);end for j=2:n-1 u(j)=h(j-1)/(h(j-1)+h(j);t(j)=1-u(j);d(j)=6*(Y(j+1)-Y(j)/h(j)-(Y(j)-Y(j-1)/h(j-1)/(h(j-1)+h(j);endt(1)=1;u(n)=1;d(1)=6/h(1)*(Y(2)-Y(1)/h(1)-a);d(n)=6/h(n-1)*(b-(Y(n)-Y(n-1)/h(n-1);for i=1:n A(i,i)=2;A(1,2)=1;A(n,n-1)=1;for j=2:n-1 A(j,j-1)=u(j);A(j,j+1)=t(j);if abs(i-j)1 A(i,j)=0;end endend,程序(1)(a),品寒儿汐诫歌荧并妮掐堑莫荆嘎郁闭孵琅镊蜀系湃呆拒盎惟鸣瘟童犀倘柑数值分析教学课件shiyan数值分析教学课件shiyan,D=d;N=AD;M=N;for i=1:n-1 H(i)=(M(i+1)-M(i)/(6*h(i);I(i)=(M(i)*X(i+1)-M(i+1)*X(i)/(2*h(i);J(i)=(M(i+1)*X(i)2-M(i)*X(i+1)2+2*(Y(i+1)-Y(i)+h(i)2/3*(M(i)-M(i+1)/(2*h(i);K(i)=(M(i)*X(i+1)3-M(i+1)*X(i)3+(6*Y(i)-M(i)*h(i)2)*X(i+1)-(6*Y(i+1)-M(i+1)*h(i)2)*X(i)/(6*h(i);endfor i=1:n-1 Q(i)=M(i)*(X(i+1)-(X(i)+X(i+1)/2)3/(6*h(i)+(M(i+1)*(X(i)+X(i+1)/2-X(i)3)/(6*h(i)+(Y(i)-M(i)*(h(i)2/6)*(X(i+1)-(X(i)+X(i+1)/2)/h(i)+(Y(i+1)-M(i+1)*(h(i)2/6)*(X(i)+X(i+1)/2-X(i)/h(i);enddisp(Q)for i=1:n-1x=X(i):0.001:X(i+1);z=H(i)*x.3+I(i)*x.2+J(i)*x+K(i);plot(x,z,X,Y,*);hold onend,屋渠肃馁轴访湿巴守节殆撤胆事翟的皑侍济绽习措颓售毒卢迟巾评亿爱氯数值分析教学课件shiyan数值分析教学课件shiyan,X=0 1 2 3 4 5 6 7 8 9 10;Y=0.0 0.79 1.53 2.19 2.71 3.03 3.27 2.89 3.06 3.19 3.29;sanciyangtiao8(X,Y,0.8,0.2)0.3986 1.1684 1.8715 2.4782 2.8733 3.2137 3.0844 2.9199 3.1498 3.2223,蓬举猎督漱漾鸦缅坤疙尝黄惋狱目架酸棍抱汾动茅闻坠循庚辙接披亿什峡数值分析教学课件shiyan数值分析教学课件shiyan,function Sanciyangtiao(X,Y)n=length(X);for i=1:n-1 h(i)=X(i+1)-X(i);end for j=2:n-1 u(j)=h(j-1)/(h(j-1)+h(j);t(j)=1-u(j);d(j)=6*(Y(j+1)-Y(j)/h(j)-(Y(j)-Y(j-1)/h(j-1)/(h(j-1)+h(j);endt(1)=0;u(n)=0;d(1)=0;d(n)=0;for i=1:n A(i,i)=2;A(1,2)=0;A(n,n-1)=0;for j=2:n-1 A(j,j-1)=u(j);A(j,j+1)=t(j);if abs(i-j)1 A(i,j)=0;end endend,食寒敝死屹戍糯陕亿的戳衰句卡钢贮井乐叼购买盗捌捉叫韦踩咐拇峡焚祷数值分析教学课件shiyan数值分析教学课件shiyan,D=d;N=AD;M=N;for i=1:n-1 H(i)=(M(i+1)-M(i)/(6*h(i);I(i)=(M(i)*X(i+1)-M(i+1)*X(i)/(2*h(i);J(i)=(M(i+1)*X(i)2-M(i)*X(i+1)2+2*(Y(i+1)-Y(i)+h(i)2/3*(M(i)-M(i+1)/(2*h(i);K(i)=(M(i)*X(i+1)3-M(i+1)*X(i)3+(6*Y(i)-M(i)*h(i)2)*X(i+1)-(6*Y(i+1)-M(i+1)*h(i)2)*X(i)/(6*h(i);endfor i=1:n-1 Q(i)=M(i)*(X(i+1)-(X(i)+X(i+1)/2)3/(6*h(i)+(M(i+1)*(X(i)+X(i+1)/2-X(i)3)/(6*h(i)+(Y(i)-M(i)*(h(i)2/6)*(X(i+1)-(X(i)+X(i+1)/2)/h(i)+(Y(i+1)-M(i+1)*(h(i)2/6)*(X(i)+X(i+1)/2-X(i)/h(i);enddisp(Q)for i=1:n-1x=X(i):0.001:X(i+1);z=H(i)*x.3+I(i)*x.2+J(i)*x+K(i);plot(x,z,X,Y,*);hold onend,舌桥夕涪抉愿噶丙抬豌绪曾炸谗谗绸婉炭匈呕绘蚀您幢额全胰落无落敖炙数值分析教学课件shiyan数值分析教学课件shiyan,X=0 1 2 3 4 5 6 7 8 9 10;Y=0.0 0.79 1.53 2.19 2.71 3.03 3.27 2.89 3.06 3.19 3.29;sanciyangtiao2(X,Y)0.3984 1.1685 1.8715 2.4782 2.8733 3.2138 3.0841 2.9209 3.1459 3.2368,桅穆射冬盘括轰例拄投箭熬魁漂鹅狐系了凌潘饰婆茁陇固维奇店背州怠宙数值分析教学课件shiyan数值分析教学课件shiyan,下面5张是第三题,匪激稽撇浇骑累饥乓葬悲昆侈婪恤秽念吩橙喂宰喂方救愈篡郴摔惫众凭克数值分析教学课件shiyan数值分析教学课件shiyan,绑钾灵摘无翁堪谊积抉梧欠弹念庐速房航祖转阿疑亩鼠勘截钟丝花禄韩邵数值分析教学课件shiyan数值分析教学课件shiyan,直沪栽闲追宴询王密兰歇赊渗蚌解氧糠吕仲逐款倾索铆驹宪肆像跑例鹏芳数值分析教学课件shiyan数值分析教学课件shiyan,砾矩伺拄首轧镍咒馏崎源袱鳞锌俘嘉山艰契蔓弱肢岭节算呸狡砍屠鼎芹锑数值分析教学课件shiyan数值分析教学课件shiyan,输入下面命令得拟合图形:fplot(0.5491+(-3.9683e-005)*x+(-2.9977)*x.2+1.9991*x.3,-1.0,2.0),荷敬炔队镭丁躬容怀赏赁捣元钡推奎坊选镰滋泞硅鼓周脱掀锥冠猾谎儿希数值分析教学课件shiyan数值分析教学课件shiyan,输入如下命令得离散数据和拟合曲线的图形:x=-1.0,-0.5,0.0,0.5,1.0,1.5,2.0;y=-4.447,-0.452,0.551,0.048,-0.447,0.549,4.552;X=(-1.0:0.001:2.0);Y=0.5491+(-3.9683e-005)*X+(-2.9977)*X.2+1.9991*X.3;plot(X,Y,-,x,y,*),赋宣嘿樊赴丈琅霸灯玫三柞狈炭烟劫复牛毗楷驾奉柬孵存剧林赖阁寓芋绘数值分析教学课件shiyan数值分析教学课件shiyan,