Question: How do i solve a diff problem with arctan. when arctan=Pi/2

As the title, who can help me fix the problem like this

theta:= diff(arctan(y,x)):

W:= piecewise(

         theta>-Pi/2 and theta< -Pi/2+10, 1+A+B*cos(theta),

         theta>-Pi/2+10 and theta< Pi/2-10. 1-A+B*cos(thea)); 

there always plotout the undefined when acrtan(y,x)=Pi/2,

How can I ignore this undefined or define another value for W when acrtan(y,x)=Pi/2

Please Wait...