Question: integration in if-statement

How can I get the evaluation of integration inside if-statement?

Thanks for your help in advance,

restart;

#L:=1:sigma:=0.01:beta:=0.2:k0:=-100:

#For Free particle
Projectile := proc({L:=1,sigma:=0.01,beta:=0.2,k0:=-100},n_max) local x0,g,c:
 x0:= beta*L;
 g := unapply(exp(-(x-x0)^2/2/sigma^2),x);
 #c := int(g(x)^2,x=-L/2..L/2,numeric=true);
 ub := (L/2-x0)/sqrt(2)/sigma;
 lb := (-L/2-x0)/sqrt(2)/sigma;
 a := Pi*sqrt(2)*sigma/L;
 b := sqrt(2)*k0*sigma;
 c := Pi*x/L;
 d := k0*x0;
 eq1 := [cos(a*n*z)*cos(b*z)/e^(z^2),cos(a*n*z)*sin(b*z)/e^(z^2),sin(a*n*z)*cos(b*z)/e^(z^2),sin(a*n*z)*sin(b*z)/e^(z^2)];
 eq1 := map(f->unapply(f,n,z),eq1);
 eq2 := [cos(n*c)*cos(d),cos(n*c)*sin(d),sin(n*c)*cos(d),sin(n*c)*sin(d)];
 eq2 := map(f->unapply(f,n,z),eq2);

 for j from 1 to n_max do:
   if (is(j,odd)) then eq11 := int(eq1[1](j,z),z=lb..ub,numeric=true);
   else 0;
   end if;
 end do:

end proc:

 

Warning, (in Projectile) `ub` is implicitly declared local

 

Warning, (in Projectile) `lb` is implicitly declared local

 

Warning, (in Projectile) `a` is implicitly declared local

 

Warning, (in Projectile) `b` is implicitly declared local

 

Warning, (in Projectile) `d` is implicitly declared local

 

Warning, (in Projectile) `eq1` is implicitly declared local

 

Warning, (in Projectile) `eq2` is implicitly declared local

 

Warning, (in Projectile) `j` is implicitly declared local

 

Warning, (in Projectile) `eq11` is implicitly declared local

 

Projectile(1);

int(cos(0.4442882938e-1*z)*cos(1.414213562*z)/e^(z^2), z = -49.49747467 .. 21.21320343)

(1)

 


Download SolnforProjectile_v3_3.mw

Please Wait...