 function F = Func1(theta,P,yrqd);
 
 % Derivative of function 1
 
 F=ppval(P,theta)*sin(theta)-yrqd;
 if theta < 0
    F=-theta^2+pi*theta-yrqd;
 elseif theta > pi
    F=-theta^2+pi*theta-yrqd;
 end;