The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Message from discussion Linear interpolation problem

```Received: by 10.68.138.14 with SMTP id qm14mr2144068pbb.5.1352317569301;
Wed, 07 Nov 2012 11:46:09 -0800 (PST)
MIME-Version: 1.0
From: "Heinrich Acker" <firstname.lastn...@web.de>
Newsgroups: comp.soft-sys.matlab
Subject: Linear interpolation problem
Date: Wed, 7 Nov 2012 19:46:09 +0000 (UTC)
Organization: Continental Teves AG &#38; Co. OHG
Lines: 33
Message-ID: <k7edq1\$akq\$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: www-05-blr.mathworks.com
X-Trace: newscl01ah.mathworks.com 1352317569 10906 172.30.248.37 (7 Nov 2012 19:46:09 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 7 Nov 2012 19:46:09 +0000 (UTC)
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Dear Matlab users,

I have the following problem, which seems to be too general for not already being solved by somebody. The interpolation error I find when using 'interp1' with the default linear method is not as small as it could be, given the linear model and the number of data points. Please consider this example:

% interval
x = 0:0.01:1;

% function
y = x.^2;

% knots to use for interpolation
xi = 0:0.1:1;

% interpolate
yi = interp1(x,y,xi);

% show function and interpolation result
plot(x,y)
hold all
plot(xi,yi,'.-')

% interpolate again, this time to find the errors at all values of x
yi2 = interp1(xi,yi,x);

% plot the error
figure
plot(x,yi2-y)

The error shown in the second figure is always positive, because of the sign of the curvature of the function. In this particular case, it would be easy to shift the yi values in order to minimize the error. In general, it seems not so easy. I can think of heavily iterative, optimizing algorithms that try to trim the result of 'interp1' in order to minimize the error. But for the data sets I am interested in, such an algorithm is likely to be too slow. I wonder if there is a solution more clever than iteratively trying to improve the result of 'interp1'. My questions are: Is there a proven, available algorithm to minimize the error for the general case? Is one available in Matlab? How is it called if it has a name?

Thank you.

Heinrich
```