Question: How do I solve a Division by zero at(1) problem [piecewise, subs, diff... ]

When I use piecewise like this

W :=piecewise(beta>=-Pi/2 and beta<=-Pi/2+Pi/200,1+eps/sin(Pi/200)+eps*cos(Pi/200)/sin(Pi/200)*sin(beta),
     
beta>=-Pi/2+Pi/200 and beta<=Pi/2,1+eps/sin(Pi/200)-eps*cos(Pi/200)/sin(Pi/200)*sin(beta),
      1+eps*(1+cos(beta)));

 

and eval the beta as following,

G:= eval(R,beta=(arctan(diff(f(x,y),y), diff(f(x,y),x))));

the calculation does not run well...because of the undefined

[[-eps sin(t_atan2((&PartialD;)/(&PartialD;y) pho(x,y),(&PartialD;)/(&PartialD;x) pho(x,y))),t_atan2((&PartialD;)/(&PartialD;y) pho(x,y),(&PartialD;)/(&PartialD;x) pho(x,y))<-Pi/2],[undefined,t_atan2((&PartialD;)/(&PartialD;y) pho(x,y),(&PartialD;)/(&PartialD;x) pho(x,y))=-Pi/2],[(eps cos(Pi/200) cos(t_atan2((&PartialD;)/(&PartialD;y) pho(x,y),(&PartialD;)/(&PartialD;x) pho(x,y))))/(sin(Pi/200)),t_atan2((&PartialD;)/(&PartialD;y) pho(x,y),(&PartialD;)/(&PartialD;x) pho(x,y))<-(99 Pi)/200],[undefined,t_atan2((&PartialD;)/(&PartialD;y) pho(x,y),(&PartialD;)/(&PartialD;x) pho(x,y))=-(99 Pi)/200],[-(eps cos(Pi/200) cos(t_atan2((&PartialD;)/(&PartialD;y) pho(x,y),(&PartialD;)/(&PartialD;x) pho(x,y))))/(sin(Pi/200)),t_atan2((&PartialD;)/(&PartialD;y) pho(x,y),(&PartialD;)/(&PartialD;x) pho(x,y))<Pi/2],[undefined,t_atan2((&PartialD;)/(&PartialD;y) pho(x,y),(&PartialD;)/(&PartialD;x) pho(x,y))=Pi/2],[-eps sin(t_atan2((&PartialD;)/(&PartialD;y) pho(x,y),(&PartialD;)/(&PartialD;x) pho(x,y))),Pi/2<t_atan2((&PartialD;)/(&PartialD;y) pho(x,y),(&PartialD;)/(&PartialD;x) pho(x,y))]]

Finally, when W is brought into the following formula for calculation, 

R:=   
-M*ElementInt( test(x,y)*((1-co(x,y))*Ha+co(x,y)*Hb))
     +M*ElementInt( test(x,y)*noise)
+M*gamma*(-ElementInt( W^2*( nab(test(x,y))[i] &t nab(f(x,y))[i])))
              +ElementInt( diff(W^2,beta)/2 * ( diff(test(x,y),x)*diff(f(x,y),y)
              -diff(test(x,y),y)*diff(f(x,y),x))):

 

the following error message will appear.

Error: Division by zero at (1)

 

I mentioned a similar problem just recently, but after two days of continuous attempts, I couldn't find a solution.
Look forward to receiving a reply.......

Please Wait...