  function [y,dy,ddy] = derBstar(z)
% z is a scalar
% y   = Bstar(z)
% dy  = Bstar'(z)
% ddy = Bstar''(z)

if -2<=z && z<=-1
    y   = (2+z)^3/6; 
    dy  = (2+z)^2/2;  
    ddy = 2+z;
elseif  -1<=z && z<=0
    y  = (-3*(1+z)^3 + 3*(1+z)^2 + 3*(1+z) + 1)/6;
    dy  = (-9*(1+z)^2+6*(1+z)+3)/6;
    ddy = (-12-18*z)/6;
elseif 0<=z && z<=1
    y   = (-3*(1-z)^3 + 3*(1-z)^2 + 3*(1-z) + 1)/6;
    dy  = (9*(1-z)^2-6*(1-z)-3)/6;
    ddy = (-12+18*z)/6;
elseif 1<=z  && z<=2
    y   = (2-z)^3/6;
    dy  = -(2-z)^2/2;
    ddy = 2-z;
else
    y   = 0;
    dy  = 0;
    ddy = 0;
end