Interpolation Methods.ppt
《Interpolation Methods.ppt》由会员分享,可在线阅读,更多相关《Interpolation Methods.ppt(40页珍藏版)》请在麦多课文档分享上搜索。
1、Interpolation Methods,Robert A. Dalrymple Johns Hopkins University,Why Interpolation?,For discrete models of continuous systems, we need the ability to interpolate values in between discrete points. Half of the SPH technique involves interpolation of values known at particles (or nodes).,Interpolati
2、on,To find the value of a function between known values.Consider the two pairs of values (x,y):(0.0, 1.0), (1.0, 2.0)What is y at x = 0.5? That is, whats (0.5, y)?,Linear Interpolation,Given two points, (x1,y1), (x2,y2):Fit a straight line between the points.y(x) = a x +ba=(y2-y1)/(x2-x1), b= (y1 x2
3、-y2 x1)/(x2-x1), Use this equation to find y values for any x1 x x2,Polynomial Interpolants,Given N (=4) data points,Find the interpolating function that goes through the points:If there were N+1 data points, the function would bewith N+1 unknown values, ai, of the Nth order polynomial,Polynomial In
4、terpolant,Force the interpolant through the four points to get four equations:,Rewriting:The solution is found by inverting p,Example,Data are: (0,2), (1,0.3975), (2, -0.1126), (3, -0.0986).Fitting a cubic polynomial through the four points gives:,Matlab code for polynomial fitting,% the data to be
5、interpolated (in 1D)x=-0.2 .44 1.0 1.34 1.98 2.50 2.95 3.62 4.13 4.64 4.94;y=2.75 1.80 -1.52 -2.83 -1.62 1.49 2.98 0.81 -2.14 -2.93 -1.81;plot(x,y,bo)n=size(x,2) % CUBIC FITp=ones(1,n)xx.*xx.*(x.*x)a=py %same as a=inv(p)*yyp=p*ahold on;plot(x,yp,k*),Note: linear and quadratic fit: redefine p,Polynom
6、ial Fit to Example,Exact: red Polynomial fit: blue,Beware of Extrapolation,An Nth order polynomial has N roots!,Exact: red,Least Squares Interpolant,For N points, we will have a fitting polynomial of order m (N-1). The least squares fitting polynomial be similar to the exact fit form: Now p is N x m
7、 matrix. Since we have fewer unknown coefficient as data points, the interpolant cannot go through each point. Define the error as the amount of “miss”Sum of the (errors)2:,Least Squares Interpolant,Minimizing the sum with respect to the coefficients a:Solving,This can be rewritten in this form,whic
8、h introduces a pseudo-inverse.,Reminder:,for cubic fit,Question,Show that the equation above leads to the following expression for the best fit straight line:,Matlab: Least-Squares Fit,%the data to be interpolated (1d)x=-0.2 .44 1.0 1.34 1.98 2.50 2.95 3.62 4.13 4.64 4.94;y=2.75 1.80 -1.52 -2.83 -1.
9、62 1.49 2.98 0.81 -2.14 -2.93 -1.81;plot(x,y,bo)n=size(x,2) % CUBIC FITp=ones(1,n)xx.*xx.*(x.*x)pinverse=inv(p*p)*pa=pinverse*yyp=p*aplot(x,yp,k*),Cubic Least Squares Example,x: -0.2 .44 1.0 1.34 1.98 2.50 2.95 3.62 4.13 4.64 4.94 y: 2.75 1.80 -1.52 -2.83 -1.62 1.49 2.98 0.81 -2.14 -2.93 -1.81,Data
10、irregularly spaced,Least Squares Interpolant,Cubic Least Squares Fit: * is the fitting polynomialo is the given data,Exact,Piecewise Interpolation,Piecewise polynomials: fit all pointsLinear: continuity in y+, y- (fit pairs of points)Quadratic: +continuity in slopeCubic splines: +continuity in secon
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- INTERPOLATIONMETHODSPPT
