Problem 4.7

meshfree 1D interpolation with compactly supported RBFs interpolation error in dependence of shape parameter

f = @(x) 4*x.*(1-x);
phi = @(S,r) max(spones(S)-r,0).^6.*(35*r.^2+18*r+3*spones(S))/3; % Wendlands \phi_3,2

N = 2^8;
X = linspace(0,1,N)'; y = f(X);
M = 2*N;
X_e = linspace(1/M,1-1/M,M)';

ep = logspace(-1,1.4,40);
for k = 1:40,
    tic
    D = sdistm(X,X,1/ep(k));
    D = phi(D+speye(size(D)),ep(k)*D);
    c = D\y;
    D_e = sdistm(X_e,X,1/ep(k));
    D_e = phi(spones(D_e),ep(k)*D_e);
    y_e = D_e*c;
    t(k) = toc;
    nz(k) = nnz(D)/size(D,1);
    cnd(k) = condest(D);
    err(k) = norm(y_e-f(X_e))/sqrt(M);
end
subplot(221);
loglog(ep,err,'o-'); grid on
xlabel('\epsilon'); ylabel('L^2-error');
subplot(222);
loglog(ep,nz,'o-'); grid on
xlabel('\epsilon'); ylabel('sparsity of D');
subplot(223);
loglog(ep,cnd,'o-'); grid on
xlabel('\epsilon'); ylabel('cond(D)');
subplot(224);
loglog(ep,t,'o-'); grid on
xlabel('\epsilon'); ylabel('cpu time');