# Problem 1.3

basic meshfree interpolation with euclidean distance basis functions

## Contents

## distm.m

```
function D = distm(X,Y)
```

% DISTM Distance matrix. % DISTM(X,Y) is the matrix of pairwise euclidean % distances between the points in the rows of X and Y % code by Paritosh Mokhasi and Gregory Fasshauer

[M,s] = size(X); [N,s] = size(Y); D = repmat(sum(X.*X,2),1,N) - 2*X*Y' + repmat((sum(Y.*Y,2))',M,1); D = sqrt(D);

## interpolation

% constructing the interpolant f = @(x) 4*x.*(1-x); N = 5; X = linspace(0,1,N)'; y = f(X); D = distm(X,X); c = D\y; % evaluating it M = 50; X_eval = linspace(0,1,M)'; D_eval = distm(X_eval,X); y_eval = D_eval*c; % plotting the function and its interpolant plot(X,0,'bo',X_eval,f(X_eval)); hold on plot(X_eval,y_eval,'rx-'); xlabel('x'); ylabel('f,P_f')