Problem 1.4

basic meshfree interpolation with euclidean distance basis functions

Contents

error in dependence of N

f = @(x) 4*x.*(1-x);
M = 1000; X_eval = linspace(0,1,M)';
N = logspace(1,2.9,20);
for k = 1:20,
    t = tic;
    X = linspace(0,1,N(k))';
    y = f(X); D = distm(X,X); c = D\y;
    y_eval = distm(X_eval,X)*c;
    T(k) = toc(t);
    err_2(k) = norm(y_eval-f(X_eval))/sqrt(M);
    err_inf(k) = norm(y_eval-f(X_eval),inf);
    cond_D(k) = condest(D);
end
clf; loglog(N,err_2,'x-',N,err_inf,'rx-');
xlabel('N'); ylabel('errors'); legend('L^2-error','L^\infty-eror')

condition number of D and cpu time for interpolation

figure;
plot(N,cond_D,'x-'); xlabel('N'); ylabel('cond(D)');
figure;
plot(N,T,'x-'); xlabel('N'); ylabel('cpu time');