function thetabxitp = thetabxitpmp(x,J,Nit)
% J is a vector describing the functions we wish to concatenate
% J has dimension Nit+1
% J will have the form Pb(l,:), i.e., the lth row of Pb
% theta_{omega} = (theta_{J(1)} \circ \theta_{J(2)} \circ ...
% \circ theta_{J((Nit)} \circ theta_{J(Nit +1)}
               A(1) = 1;
               B(1) = J(1);
	       if (Nit > 0)
                 A(2) = J(2)*A(1);
                 B(2) = 1 + J(2)*B(1);
               end
if Nit ==0
  	       thetabxitx  = mp(1/(x+ J(1)));
	       thetabxitp  = mp(thetabxitx*thetabxitx);
elseif Nit == 1
               denomx = mp(B(1)*x + B(2));
	       thetabxitx = mp((x + J(2))/denomx);
	       thetabxitp = mp(1/(denomx*denomx));
else
               for n= 2:Nit
         	       A(n+1) = A(n-1) + J(n+1)*A(n);
	               B(n+1) = B(n-1) + J(n+1)*B(n);
               end
               denomx = mp(B(Nit)*x + B(Nit+1));
               thetabxitx = mp((A(Nit)*x + A(Nit+1))/denomx);
	       thetabxitp = mp(1/(denomx*denomx));
end

% end of function thetabxitpmp(x,J,Nit)
