% make a tempered step function with three continuous derivatives
%
% Use piecewise cubic polynomial on [0,r] and [r, 2r]
% f is function, df is first derivative, d2f is second derivative,
% d3f is third derivative.
%
% jbr, 1/12/2013
%
L = 1; r = L/2;
npts = 51;
x = linspace(0, L, npts)';
f1 = (1/4)*(5*(x/r).^4 - 3*(x/r).^5);
z = (2*r-x)/r;
f2 = -(1/4)*(5*z.^4 - 3*z.^5) + 1;
f = (x<=r).*f1 + (x >r).*f2;
pts = [0,1; 1,0];
lines = [-1,1; 0,1; 0,0; 2,0];
z = flipud(x);
figure()
plot(z,f, pts(:,1),pts(:,2), 'o', lines(:,1),lines(:,2))
% store numbers for plotting
smooth = [z, f];
save indicator.dat smooth pts lines