




已阅读5页,还剩18页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
数值分析 课程设计多项式插值的振荡现象(姓名)(学号)指导教师 学院名称专 业 名 称提交日期2012年6月一、 问题的提出考虑在一个固定区间上用插值逼近一个函数。显然,Lagrange插值中使用的节点越多,插值多项式的次数就越高。我们自然关心插值多项式增加时,Ln(x)是否也更加靠近被逼近的函数。龙格(Runge)给出的一个例子是极著名并富有启发性的。设区间-1,1上的函数考虑区间-1,1的一个等距划分,节点为则拉格朗日插值多项式为其中的ai(x),i=0,1,2,n是n次Lagrange插值基函数。二、 实验内容研究以下三个函数在各自区间上运用不同的划分1、2、3、运用在区间-p,p上等距划分(p0),节点为以x0,x1,xn为插值节点构造上述各函数的Lagrange插值多项式。运用区间a,b上切比雪夫(Chebychev)点的定义为以x1,x2,xn+1为插值节点构造上述各函数的Lagrange插值多项式,比较其结果。并分别比较两种划分方法,增加节点数,最大误差的变化。三、 实验结果及分析(一) 等距划分对于函数来说,使用等距划分其中绿色点线代表误差,红色划线代表Lagrange插值多项式,蓝色实线代表原函数。可见对于等距划分来说节点数越多,最大误差越大,可是越靠近中间的误差越少。越接近两个端点的误差越大。当节点数很大时,最大误差的来源只与靠近两个端点的误差有关。例如:n=20时对于,使用等距划分当n=25时对于,使用等距划分当n=30时,从以上三个函数图像来看,可见节点越多,靠近端点处取得最大误差,并且最大误差越大。这就是龙格现象。(二) 切比雪夫(Chebychev)点首先研究 当n=20时可是当n=30同样的n=40,50也出现了两端误差增大现象。 然后研究 当n=25时同样的n=30,50也会出现龙格现象。最后研究当n=25时 此函数也不例外。由以上三个函数,通过不断改变n的值,可得运用切比雪夫点来划分,要使最大误差小于0.1,n一般取12到20间的数。(三) 综述对于Lagrange插值多项式,运用等距划分取节点时,n要不能取得太大,一般n=8或8左右。若要使n取得更大,那么需要使代入到函数的点尽量在区间的中间,这样才能使真值与计算出来的值的误差尽可能的小。运用切比雪夫点来划分取节点时,n一般取12到20间的数。无论要代入到函数的点在区间的那个位置,都能使误差尽可能的小。若要使n取得更大,那么需要使代入到函数的点尽量在区间的中间,这样才能使真值与计算出来的值的误差尽可能的小。若n取的较小,同样误差也是很大的。对于以上两种取节点的方法,都不能避免龙格现象的出现。对于不同的选取节点的方法,只要n取得合适,同时代人函数的点适合,那么就可以使误差尽可能的减少。四、 关于本设计的体会为了完成本设计,接触了一个数学软件matlab,并能初步运用本软件,编写程序,方便了以后对数学的研究。并且对于编写过程中遇到的错误,显示不正确等,通过网络搜索查询,能解决这些问题。例如运用fminbnd函数时,显示的并不是正确的答案,后来百度了一下,明白了此函数的运作原理,并最终能显示我想得到的结果。当然对于我所编写的程序,我也就只能做到这一步,也是碍于时间关系,和对matlab不熟悉,并不能更好的完善下去。有时取值很大时,运行起来,运行得很慢,这是一大缺陷。主要是循环次数太多,和找不到更好的函数代替所造成的。其他的缺点也就不一一的列举了。学习一个软件需要耐心,细心。多寻找,多发现,多创作才能深入了解一个软件。同样的道理,这也是做任何事所需要的素质。五、 参考文献数值分析(第三版)北京理工大学出版社六、 附录所的运用软件及编号MATLAB 7.0(图略) 所用电脑的版本、型号与系统(图略)用户界面设计文件名:kcsjx.fig用户界面程序,运行kcsjx.m来调用主要程序文件名:kcsjx.mfunction varargout = kcsjx(varargin)% KCSJX M-file for kcsjx.fig% KCSJX, by itself, creates a new KCSJX or raises the existing% singleton*.% H = KCSJX returns the handle to a new KCSJX or the handle to% the existing singleton*.% KCSJX(CALLBACK,hObject,eventData,handles,.) calls the local% function named CALLBACK in KCSJX.M with the given input arguments.% KCSJX(Property,Value,.) creates a new KCSJX or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before kcsjx_OpeningFunction gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to kcsjx_OpeningFcn via varargin.% *See GUI Options on GUIDEs Tools menu. Choose GUI allows only one% instance to run (singleton).% See also: GUIDE, GUIDATA, GUIHANDLES% Copyright 2002-2003 The MathWorks, Inc.% Edit the above text to modify the response to help kcsjx% Last Modified by GUIDE v2.5 04-Jun-2012 16:03:46% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct(gui_Name, mfilename, . gui_Singleton, gui_Singleton, . gui_OpeningFcn, kcsjx_OpeningFcn, . gui_OutputFcn, kcsjx_OutputFcn, . gui_LayoutFcn, , . gui_Callback, );if nargin & ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);endif nargout varargout1:nargout = gui_mainfcn(gui_State, varargin:);else gui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT% - Executes just before kcsjx is made visible.function kcsjx_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to kcsjx (see VARARGIN)% Choose default command line output for kcsjxhandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes kcsjx wait for user response (see UIRESUME)% uiwait(handles.figure1);% - Outputs from this function are returned to the command line.function varargout = kcsjx_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line output from handles structurevarargout1 = handles.output;function edit1_Callback(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,String) returns contents of edit1 as text% str2double(get(hObject,String) returns contents of edit1 as a doubleinput = str2num(get(hObject,String);if (isempty(input) set(hObject,String,0)endguidata(hObject, handles); % - Executes during object creation, after setting all properties.function edit1_CreateFcn(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction edit2_Callback(hObject, eventdata, handles)% hObject handle to edit2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,String) returns contents of edit2 as text% str2double(get(hObject,String) returns contents of edit2 as a doubleinput = str2num(get(hObject,String); if (isempty(input) set(hObject,String,0) endguidata(hObject, handles); % - Executes during object creation, after setting all properties.function edit2_CreateFcn(hObject, eventdata, handles)% hObject handle to edit2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction edit3_Callback(hObject, eventdata, handles)% hObject handle to edit3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,String) returns contents of edit3 as text% str2double(get(hObject,String) returns contents of edit3 as a doubleinput = str2num(get(hObject,String); if (isempty(input) set(hObject,String,0) endguidata(hObject, handles); % - Executes during object creation, after setting all properties.function edit3_CreateFcn(hObject, eventdata, handles)% hObject handle to edit3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);end% - Executes on button press in pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)tic;v=get(handles.edit1,String);t=get(handles.edit2,String);n=get(handles.edit3,String);kcsj(str2num(t),str2num(v),str2num(n);toc;clear;% - Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)tic;v=get(handles.edit1,String);t=get(handles.edit2,String);kcsj(str2num(t),str2num(v);toc;clear;以下为主要程序。并且可以直接在命令框调用例如:在命令框输入 kcsj(1,1,3) %代表选择等距划分,选择f(x)=1/(1+25*x2)输出结果为:以下有具体说明。主程序文件名:kcsj.mfunction kcsj(t,v,n)%t为对不同x选择的判断,t=0时为等距划分,t=1时为Chebychev划分%v=1是选择f(x)=1/(1+25*x2);v=2是f(x)=x/(1+x4);v=3是f(x)=atan(x)% 函数的选取%if v=1 %题目要求不同函数,x有不同的取值范围 p=1; %x取值范围为-1,1 f=1/(1+25*x2);else if v=2 p=5; %x取值范围为-5,5 f=x/(1+x4); else if v=3 p=5; f=atan(x); end endendif t=0 P=等距划分;else P=Chebychev;endF=inline(f); %inline为将用字符串表示的函数表达式化为函数表达式%以下为不输入n值得情况%if nargin=2 for n=2:3:17 %节点数由2至11进行循环操作 X=zeros(n+1,1); %有n+1个节点 Y=zeros(n+1,1); %对应有n+1个插值% 选择节点选取方式 % if t=0 for i=0:n X(i+1,1)=-p+2*p*i/n; %等距划分 end % else % for i=1:n+1 % X(i,1)=p*cos(2*i-1)*pi/(2*(n+1);%Chebychev划分 end end% 计算差值 % for i=0:n Y(i+1,1)=F(X(i+1,1); end% 通过差值与节点得出Lagrange公式 % Pn=Lagrange3(X,Y); %调用拉格朗日函数进行 Ln=inline(Pn);% 计算原函数与Ln两个函数间的最大误差 % maxe=-abs(,char(Pn),-,f,); max=inline(abs(,char(Pn),-,f,); maxe=fmin(maxe,X); %调用fmin.m查找函数最小值 maxe=abs(maxe); %得出最大误差% 画出函数图像 % figure(v+t*3); %图像窗口的编号 subplot(2,3,(n+1)/3); %subplot用于在同一窗口什么位置显示图像 fplot(f,-p,p,c.-); %画出原函数 if (n+1)/3)=2 %添加适当的标题 title(f,P); end hold on %多个函数在同一个图像表达 fplot(Ln,-p,p); %画出拉格朗日图像 xlabel(n=,num2str(n),最大误差=,num2str(maxe);%在x轴标注n节点的取值与最大误差 fplot(max,-p,p,r:); %画出误差图像 hold off end%以下为输入n值得情况%else if nargin=3 X=zeros(n+1,1); %有n+1个节点 Y=zeros(n+1,1); %对应有n+1个插值% 选择节点选取方式 % if t=0 for i=0:n X(i+1,1)=-p+2*p*i/n; %等距划分 end % else % for i=1:n+1 % X(i,1)=p*cos(2*i-1)*pi/(2*(n+1);%Chebychev划分 end end% 计算差值 % for i=0:n Y(i+1,1)=F(X(i+1,1); end% 通过差值与节点得出Lagrange公式 % Pn=Lagrange3(X,Y); %调用拉格朗日函数进行 Ln=inline(Pn);% 计算原函数与Ln两个函数间的最大误差 % maxe=-abs(,char(Pn),-,f,); max=inline(abs(,char(Pn),-,f,); maxe=fmin(maxe,X); %调用fmin.m查找函数最小值 maxe=abs(maxe); %得出最大误差% 画出函数图像 % figure(v+t*3); %图像窗
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 健康知识培训资料及考卷课件
- 北京市顺义区2023-2024学年九年级下学期中考适应性训练(三模)历史试卷及答案
- 评价器奖惩管理办法
- 新质生产力高质量发展大会
- 学校食堂食品安全突发事件应急处置预案
- 新疆维吾尔自治区高级导游等级考试(导游综合知识)综合能力测试题及答案(2025年)
- 出租车公司安全培训总结课件
- 出国劳务业务课件
- 2025合同审批流程和合同文档管理规范采购合同协议书
- 2025年FIDIC合同框架下EPC工程总承包管理培训教材
- 李毓佩数学历险记
- 3D打印技术(课件)
- (完整版)【钢琴谱】大鱼钢琴谱
- (完整word版)英语四级单词大全
- 取暖器市场需求分析报告
- MATLAB 应用全套课件
- 双侧壁导坑施工工法
- 《培生·小学英语分级阅读80篇》四年级-这套资料难度系数较大
- 2023山东济南市长清区教体系统所属事业单位招聘22人(共500题含答案解析)笔试历年难、易错考点试题含答案附详解
- 城市轨道交通车辆制动系统PPT(高职)完整全套教学课件
- 故宫宫廷文化公司介绍
评论
0/150
提交评论