function [f] = CPB(Nz, xA, A, B, PAR1, PAR2)

    d1 = A*xA; % This is the first order derivative
    d2 = B*xA; % This is the second order derivative
    
    f(1) = xA(1)-1;
    
    for i = 2:(Nz-1)
       f(i) = d2(i) - PAR1*d1(i) - PAR2*log(1/1-0.5*xA(i));
    end
    
    f(Nz) = d1(Nz);

end