Dkunb

65 Reputation

3 Badges

2 years, 195 days

MaplePrimes Activity


These are questions asked by Dkunb

What should I do to simplify eq13 further using trig sum identities?
Thank you for your help in advance,

restart;

phi := (x,n,L) -> sqrt(2/L)*sin(n*Pi*x/L + 1/2*n*Pi);

proc (x, n, L) options operator, arrow; sqrt(2/L)*sin(n*Pi*x/L+(1/2)*n*Pi) end proc

(1)

 

eq1 := W[n,m](q,p) = simplify(1/Pi*Int(phi(q+y,n,L)*exp(-2*I*p*y)*phi(q-y,m,L),y=-L/2+abs(q)..L/2-abs(q)));

W[n, m](q, p) = 2*(Int(sin((1/2)*n*Pi*(2*q+2*y+L)/L)*exp(-(2*I)*p*y)*sin((1/2)*m*Pi*(2*q-2*y+L)/L), y = -(1/2)*L+abs(q) .. (1/2)*L-abs(q)))/(L*Pi)

(2)

eq2 := simplify(convert(eq1,int)) assuming(n,integer,m,integer);

W[n, m](q, p) = (-16*(I*((-(1/4)*m^2-(1/4)*n^2)*Pi^2+p^2*L^2)*L*p*sin(n*Pi*(abs(q)+q)/L)+(1/2)*cos(n*Pi*(abs(q)+q)/L)*(((1/4)*m^2-(1/4)*n^2)*Pi^2+p^2*L^2)*n*Pi)*exp(I*p*(L-2*abs(q)))*sin(m*Pi*(L-abs(q)+q)/L)+16*exp(-I*p*(L-2*abs(q)))*(I*L*p*((-(1/4)*m^2-(1/4)*n^2)*Pi^2+p^2*L^2)*sin(m*Pi*(abs(q)+q)/L)-(1/2)*cos(m*Pi*(abs(q)+q)/L)*m*((-(1/4)*m^2+(1/4)*n^2)*Pi^2+p^2*L^2)*Pi)*sin(n*Pi*(L-abs(q)+q)/L)+8*Pi*(-m*exp(I*p*(L-2*abs(q)))*((((1/4)*m^2-(1/4)*n^2)*Pi^2-p^2*L^2)*sin(n*Pi*(abs(q)+q)/L)+I*L*p*Pi*n*cos(n*Pi*(abs(q)+q)/L))*cos(m*Pi*(L-abs(q)+q)/L)+exp(-I*p*(L-2*abs(q)))*cos(n*Pi*(L-abs(q)+q)/L)*n*((((1/4)*m^2-(1/4)*n^2)*Pi^2+p^2*L^2)*sin(m*Pi*(abs(q)+q)/L)+I*L*p*Pi*m*cos(m*Pi*(abs(q)+q)/L))))/((m-n)^2*(m+n)^2*Pi^5-8*L^2*p^2*(m^2+n^2)*Pi^3+16*L^4*p^4*Pi)

(3)

Wigner function evaluated for q > 0 and q < 0, respectively

eq10 := simplify(eq2) assuming(q>0);
eq11 := simplify(eq2) assuming(q<0);
eq12 := simplify(eq10) assuming(m,integer,n,integer);
eq13 := simplify(eq11) assuming(m,integer,n,integer);

W[n, m](q, p) = (16*exp(-I*p*(L-2*q))*(I*p*L*((-(1/4)*m^2-(1/4)*n^2)*Pi^2+p^2*L^2)*sin(n*Pi)+(1/2)*cos(n*Pi)*Pi*n*(((1/4)*m^2-(1/4)*n^2)*Pi^2+p^2*L^2))*sin(2*m*Pi*q/L)-16*exp(I*p*(L-2*q))*(I*p*L*((-(1/4)*m^2-(1/4)*n^2)*Pi^2+p^2*L^2)*sin(m*Pi)-(1/2)*Pi*cos(m*Pi)*((-(1/4)*m^2+(1/4)*n^2)*Pi^2+p^2*L^2)*m)*sin(2*n*Pi*q/L)+8*Pi*(exp(-I*p*(L-2*q))*((((1/4)*m^2-(1/4)*n^2)*Pi^2-p^2*L^2)*sin(n*Pi)+I*L*n*p*Pi*cos(n*Pi))*m*cos(2*m*Pi*q/L)-((((1/4)*m^2-(1/4)*n^2)*Pi^2+p^2*L^2)*sin(m*Pi)+I*L*m*p*Pi*cos(m*Pi))*cos(2*n*Pi*q/L)*n*exp(I*p*(L-2*q))))/((m-n)^2*(m+n)^2*Pi^5-8*L^2*p^2*(m^2+n^2)*Pi^3+16*L^4*p^4*Pi)

 

W[n, m](q, p) = (-8*exp(I*p*(L+2*q))*n*(((1/4)*m^2-(1/4)*n^2)*Pi^2+p^2*L^2)*sin(m*Pi*(L+2*q)/L)+8*m*(-exp(-I*p*(L+2*q))*((-(1/4)*m^2+(1/4)*n^2)*Pi^2+p^2*L^2)*sin(n*Pi*(L+2*q)/L)+I*Pi*n*p*L*(cos(n*Pi*(L+2*q)/L)*exp(-I*p*(L+2*q))-exp(I*p*(L+2*q))*cos(m*Pi*(L+2*q)/L))))/((m-n)^2*(m+n)^2*Pi^4-8*L^2*p^2*(m^2+n^2)*Pi^2+16*L^4*p^4)

 

W[n, m](q, p) = (8*(-1)^n*(((1/4)*m^2-(1/4)*n^2)*Pi^2+p^2*L^2)*n*exp(-I*p*(L-2*q))*sin(2*m*Pi*q/L)-8*m*(-(-1)^m*exp(I*p*(L-2*q))*((-(1/4)*m^2+(1/4)*n^2)*Pi^2+p^2*L^2)*sin(2*n*Pi*q/L)+I*n*(cos(2*n*Pi*q/L)*exp(I*p*(L-2*q))*(-1)^m-exp(-I*p*(L-2*q))*(-1)^n*cos(2*m*Pi*q/L))*Pi*L*p))/((m-n)^2*(m+n)^2*Pi^4-8*L^2*p^2*(m^2+n^2)*Pi^2+16*L^4*p^4)

 

W[n, m](q, p) = (-8*exp(I*p*(L+2*q))*n*(((1/4)*m^2-(1/4)*n^2)*Pi^2+p^2*L^2)*sin(m*Pi*(L+2*q)/L)+8*m*(-exp(-I*p*(L+2*q))*((-(1/4)*m^2+(1/4)*n^2)*Pi^2+p^2*L^2)*sin(n*Pi*(L+2*q)/L)+I*Pi*n*p*L*(cos(n*Pi*(L+2*q)/L)*exp(-I*p*(L+2*q))-exp(I*p*(L+2*q))*cos(m*Pi*(L+2*q)/L))))/((m-n)^2*(m+n)^2*Pi^4-8*L^2*p^2*(m^2+n^2)*Pi^2+16*L^4*p^4)

(4)
 

 

Download test5.mw

In my code, why  does InitState(5,5) return only one element of the vector while Coherent(5) returns 5 elements of the vector?

restart;

with(LinearAlgebra):

 

Coherent := proc({zeta:=1,phi:=Pi/2},n_max) local alpha,i,ICs:
 #alpha := sqrt(zeta)*exp(I*phi):
 ICs := Vector(n_max,i->evalc(evalf(exp(-zeta/2)/sqrt((i-1)!))*(sqrt(zeta)*exp(I*phi))^(i-1)),datatype=complex[8]);
end proc:

Projectile := proc({L:=1,sigma:=0.01,beta:=0.02,k0:=-5*Pi},n_max) local x0,g,c,v,ICs,j:
  x0 := evalf(beta*L);
  g := unapply(exp(-(x-x0)^2/2/sigma^2),x);
  c := evalf(int(g(x)^2,x=-L/2..L/2,numeric=true));
 
  v:=Vector(n_max,datatype=complex[8]);

  for j from 1 to n_max do:
     if (is(j,odd)) then  v[j]:= evalc[8](evalf(Int(cos(Pi*j*x/L)*g(x)*cos(k0*x),x=-L/2..L/2,method=_d01akc))+ I*evalf(Int(cos(Pi*j*x/L)*g(x)*sin(k0*x),x=-L/2..L/2,method=_d01akc)));
      else v[j]:= evalc[8](evalf(Int(sin(Pi*j*x/L)*g(x)*cos(k0*x),x=-L/2..L/2,method=_d01akc))+ I*evalf(Int(sin(Pi*j*x/L)*g(x)*sin(k0*x),x=-L/2..L/2,method=_d01akc)));
     end if:
  end do:

 ICs :=evalf[8](sqrt(2/L*c))*v;
end proc:

InitState := proc({zeta:=1,phi:=Pi/2,L:=1,sigma:=0.01,beta:=0.02,k0:=-5*Pi},d1,d2) local Z0:
z1 := Coherent(zeta,phi,d1);
#Z0:= MatrixMatrixMultiply(Coherent(zeta,phi,d1),Transpose(Projectile(L,sigma,beta,k0,d2))):
end proc:

Warning, (in InitState) `z1` is implicitly declared local

 

InitState(5,5); Coherent(5);

Vector(1, {(1) = .6065306597+0.*I})

 

Vector[column](%id = 36893490076814315516)

(1)
 

 

Download test3.mw

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

How can I make if-statement work in my code?
assuming m,n :: integers
Thank you in advance.

restart;

 

x2 := proc(m,n)
  if ((is(m,even) and is(n,odd)) or (is(m,odd)and is(n,even))) then -8*L*m*n/(m+n)^2/Pi^2/(m-n)^2;
  else  0;
  end if;
end poc:

Error, missing operator or `;`

 


Download test2.mw

How can I  get the result for the integration when m =n or m is not equal to n and How can I add assumption that m, or n can be even or odd?

Thanks in advance for your help.

 

restart;
phi := proc(k,x,L)
  if (type(k,even)) then sqrt(2)*sin(Pi*k*x/L)/sqrt(L)
  else sqrt(2)*cos(Pi*k*x/L)/sqrt(L)
  end if;
end proc:

Int(phi(m,x,L)*_h^2/m2*diff(phi(n,x,L),x,x),x=-L/2..L/2);

Int(-2*cos(Pi*m*x/L)*_h^2*Pi^2*n^2*cos(Pi*n*x/L)/(L^3*m2), x = -(1/2)*L .. (1/2)*L)

(1)
 

 

Download test1.mw

 

1 2 3 4 5 Page 1 of 5