# MA 5324 Problem 3.6

meshfree 1D interpolation with compactly supported RBFs here: comparison of full vs. sparse version

## Contents

## setup

f = @(x) 4*x.*(1-x); % Wendlands \phi_3,2, full and sparse version phi = @(r) max(1-r,0).^6.*(35*r.^2+18*r+3)/3; phis = @(r) max(spones(r)-r,0).^6.*(35*r.^2+18*r+3*spones(r))/3; N = 4000; % vary this X = linspace(0,1,N)'; y = f(X); M = 2*N; X_e = linspace(1/M,1-1/M,M)'; % has to be disjoint from X (sparsity structure) ep = N/3; % vary this

## full version

tic D = distm(X,X); D = phi(ep*D); c = D\y; D_e = distm(X_e,X); D_e = phi(ep*D_e); y_e = D_e*c; err = norm(y_e-f(X_e))/sqrt(M) toc

err = 0.0023 Elapsed time is 3.556564 seconds.

## sparse version

tic ep = N/3; D = sdistm(X,X,1/ep); D = phis(ep*D); c = D\y; D_e = sdistm(X_e,X,1/ep); D_e = phis(ep*D_e); y_e = D_e*c; err = norm(y_e-f(X_e))/sqrt(M) toc

err = 0.0023 Elapsed time is 0.268917 seconds.