已阅读5页,还剩4页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
chapter 3interpolationinterpolation is the process of defining a function that takes on specified values at specified points. this chapter concentrates on two closely related interpolants, the piecewise cubic spline and the shape-preserving piecewise cubic named “pchip”.3.1 the interpolating polynomialwe all know that two points determine a straight line. more precisely, any two points in the plane, and, with , determine a unique first degree polynomial in whose graph passes through the two points. there are many different formulas for the polynomial, but they all lead to the same straight line graph.this generalizes to more than two points. given points in the plane, ,, with distinct s, there is a unique polynomial in of degree less than whose graph passes through the points. it is easiest to remember that , the number of data points, is also the number of coefficients, although some of the leading coefficients might be zero, so the degree might actually be less than . again, there are many different formulas for the polynomial, but they all define the same function.this polynomial is called the interpolating polynomial because it exactly re- produces the given data.,later, we examine other polynomials, of lower degree, that only approximate the data. they are not interpolating polynomials.the most compact representation of the interpolating polynomial is the la- grange form.there are terms in the sum and terms in each product, so this expression defines a polynomial of degree at most . ifis evaluated at , all the products except the th are zero. furthermore, the th product is equal to one, so the sum is equal to and the interpolation conditions are satisfied.for example, consider the following data set:x=0:3;y=-5 -6 -1 16;the commanddisp(x;y)displays 0123-5-6-116the lagrangian form of the polynomial interpolating this data iswe can see that each term is of degree three, so the entire sum has degree at most three. because the leading term does not vanish, the degree is actually three. moreover, if we plug in or 3, three of the terms vanish and the fourth produces the corresponding value from the data set.polynomials are usually not represented in their lagrangian form. more fre- quently, they are written as something likethe simple powers of x are called monomials and this form of a polynomial is said to be using the power form.the coefficients of an interpolating polynomial using its power form,can, in principle, be computed by solving a system of simultaneous linear equationsthe matrix of this linear system is known as a vandermonde matrix. its elements arethe columns of a vandermonde matrix are sometimes written in the opposite order, but polynomial coefficient vectors in matlab always have the highest power first.the matlab function vander generates vandermonde matrices. for our ex- ample data set,v = vander(x)generatesv =00011111842127931thenc = vycomputes the coefficientsc =1.00000.0000-2.0000-5.0000in fact, the example data was generated from the polynomial .one of the exercises asks you to show that vandermonde matrices are nonsin- gular if the points are distinct. but another one of the exercises asks you to show that a vandermonde matrix can be very badly conditioned. consequently, using the power form and the vandermonde matrix is a satisfactory technique for problems involving a few well-spaced and well-scaled data points. but as a general-purpose approach, it is dangerous.in this chapter, we describe several matlab functions that implement various interpolation algorithms. all of them have the calling sequencev = interp(x,y,u)the first two input arguments, and , are vectors of the same length that define the interpolating points. the third input argument, , is a vector of points where the function is to be evaluated. the output, v, is the same length as u and has elements our first such interpolation function, polyinterp, is based on the lagrange form. the code uses matlab array operations to evaluate the polynomial at all the components of u simultaneously.function v = polyinterp(x,y,u)n = length(x);v = zeros(size(u);for k = 1:nw = ones(size(u);for j = 1:k-1 k+1:nw = (u-x(j)./(x(k)-x(j).*w;endendv = v + w*y(k); to illustrate polyinterp, create a vector of densely spaced evaluation points.u = -.25:.01:3.25;thenv = polyinterp(x,y,u);plot(x,y,o,u,v,-)creates figure 3.1.figure 3.1. polyinterpthe polyinterp function also works correctly with symbolic variables. for example, createsymx = sym(x)then evaluate and display the symbolic form of the interpolating polynomial withp = polyinterp(x,y,symx)pretty(p)produces-5 (-1/3 x + 1)(-1/2 x + 1)(-x + 1) - 6 (-1/2 x + 3/2)(-x + 2)x-1/2 (-x + 3)(x - 1)x + 16/3 (x - 2)(1/2 x - 1/2)xthis expression is a rearrangement of the lagrange form of the interpolating poly- nomial. simplifying the lagrange form withp = simplify(p)changes p to the power formp =x3-2*x-5here is another example, with a data set that is used by the other methods in this chapter.x = 1:6;y = 16 18 21 17 15 12;disp(x; y)u = .75:.05:6.25;v = polyinterp(x,y,u);plot(x,y,o,u,v,-);produces123456161821171512creates figure 3.2.figure 3.2. full degree polynomial interpolationalready in this example, with only six nicely spaced points, we can begin to see the primary difficulty with full-degree polynomial interpolation. in between the data points, especially in the first and last subintervals, the function shows excessive variation. it overshoots the changes in the data values. as a result, full- degree polynomial interpolation is hardly ever used for data and curve fitting. its primary application is in the derivation of other numerical methods.第三章 插值多项式插值就是定义一个在特定点取给定值得函数的过程。本章的重点是介绍两个紧密相关的插值函数:分段三次样条函数和保形分段三次插值函数(称为“pchip”)3.1插值多项式人们知道两点确定一条直线,或者更确切地说,平面上任意两点和,只要,就唯一确定一个关于的一次多项式,其图形经过这两个点。对于这个多项式,有多种不同的公式表示,但是它们都对应同一个图形。把上述讨论推广到多于两个点的情况。则对于平面上有着不同值的个点,存在唯一一个关于的次数小于的多项式,使其图形经过这些点。很容易可看出,数据点的数目也是多项式系数的个数。尽管,一些首项的系数可能是零,但多项式的次数实际上也小于。同样,这个多项式可能有不同的公式表达式,但它们都定义着同一个函数。这样的多项式称为插值(interpolating)多项式,它可以准确地重新计算出初始给定的数据:,后面,我们会考察另外一些较低次的多项式,这些多项式只能接近给定的数据,因此它们不是插值多项式。表示插值多项式的最紧凑的方式是拉格朗日(lagrange)形式在这个公式中,对项进行亲和,而每一个连乘符号中含有项,因此它定义的多项式最高次数为。当时计算,除了第项外,其他的乘积都为零,同时,这第项乘积正好为1,所以求和结果为,满足插值条件。例如,考虑下面一组数据。x=0:3;y=-5 -6 -1 16;输入命令disp(x;y)其输出为 0 1 2 3 -5 -6 -1 16这些数据的拉格朗日形式的多项式为可以看出上式为四个三次多项式求和,因此最后结果最高为三。由于求和后最高次项系数不为零,所以此式就是一个三次多项式。而且,如果将或者3代入上式,其中有三项都为零,而第四项结果正好符合给定数据。一个多项式通常不用拉格朗日形式表示,它更常见地写成类似的形式。其中简单的的次方项称为单项式(momomial),而多项式的这种形式称为使用幂形式(power form)的多项式。插值多项式使用幂形式表示为其中的系数,原则上可以通过求解下面的线性代数方程组得到。这个线性方程组的系数矩阵记为,也被称为范德尔蒙(vandermonde)矩阵,该矩阵的各个元素为上述范德尔蒙矩阵的各列,有时也按相反的顺序排列,但在matlab中,多项式系数向量,通常按从高次幂到低次幂排列。matlab中的函数vander可以生成范德尔蒙矩阵,例如对于前面的那组数据,v=vander(x)生成v = 0 0 0 1 1 1 1 1 8 4 2 1 27 9 3 1然后,输入命令c=vy计算出插值系数。c = 1.0000 0.0000 -2.0000 -5.0000事实上,这个例子的数据就是根据多项式生成的。在本章的习题3.6中,要证明当插值点的位置互不相同时,范德尔蒙矩阵是非奇异的。而在练习3.19中,则请读者证明范德尔蒙矩阵的条件可能非常差。通过两个练习我们可以发现,对于一组间隔比较均匀、函数值变化不大的数据,适合采用幂形式的插值多项式和范德尔蒙矩阵进行求解。但对于一般的问题,这个方法有时是危险的。在本章中,将介绍几个能实现各种插值算法的matlab函数,它们都采用下面的调用格式前两个输入参数,和,是长度相同的向量,它们定义了插值点。第三个参数,为要计算函数值的范围上的点组成的向量。输出向量和长度相等,其分量。要介绍的第一个这样的插值函数是polyinterp,它基于拉格朗日形式。程序使用了matlab的数组操作,来同时计算出多项式在向量各分量上的值。function v=plyinterp(x,y,u)n=lengt
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 术中冰冻病理诊断工作制度与流程
- 烟道保温专项施工方案计划
- 成品保护方案及措施
- 2024-2025学年高一上学期期末复习【第三章 函数的概念与性质】十大题型归纳(基础篇)(含答案)
- 党员活动室管理制度范文
- 智能化桥梁监测与维护方案
- 高血压的护理措施
- 港口货物装卸悬挂式起重机方案
- 物联网设备采购与集成合同
- 农村社会保障制度整合优化方案
- 北京市2023-2024学年七年级上学期期末考试数学试题(含答案)2
- 学校义务教育均衡发展一校一策方案
- ASTM-D3359-(附著力测试标准)-中文版
- 高校实验室安全通识课学习通超星期末考试答案章节答案2024年
- DBJ15-22-2021-T 锤击式预应力混凝土管桩工程技术规程(广东省)
- 银行客户经理招聘面试题与参考回答(某大型集团公司)
- 《安全系统工程》期末考试卷及答案
- 数学师范-大学生职业生涯规划书
- 科学阅读材料(课件)二年级上册科学教科版
- 2022年度尾矿库安全风险辨识及分级管控表
- 投标项目进度计划
评论
0/150
提交评论