Question:help evaluating an integrand - integrating in u still returns u

Question:help evaluating an integrand - integrating in u still returns u

Hello,

I have a huge expression involving psi and phi called A_1 which I paste below.  I am trying to integrate it using the residue theorem in the variable phi. I make a substitution in u as below for sin(k*phi)  and ask for the singularities of each operand at u. But when I get my final result it still has the variable u in it. If its evaluated the integral in u then it should not return u in the result. Evidently it’s done something wrong but I just can’t see what it is. Would you please help me? I’d be grateful for any help. My objective is to integrate A_1 in phi (Maple couldn’t  do it directly so I use residue theorem).  So what I do is for each operand in A_1 I remove terms in psi, I substitute u as below for sin(k*phi), I find the singularity at u, get the residues at those singularities and sum them then multiply by 2*Pi*I. I apologise for the huge output.

This is my expression to evaluate:

(1/(2*Pi)+sin(k*phi))^3*(-320*Pi^2*(((((1/20)*Pi^3-1/1280*I+(1/160)*Pi+(3/80*I)*Pi^4+(1/10*I)*Pi^6)*sin(k*phi)^3-(1/20*(-(3/4)*Pi^4+(1/8*I)*Pi+I*Pi^3-2*Pi^6+1/64))*cos(k*phi)*sin(k*phi)^2+(1/10*(1+cos(k*phi)^2))*((1/16)*Pi-1/128*I+(3/8*I)*Pi^4+I*Pi^6+(1/2)*Pi^3)*sin(k*phi)-(1/20*(-(3/4)*Pi^4+(1/8*I)*Pi+I*Pi^3-2*Pi^6+1/64))*cos(k*phi)*(cos(k*phi)+1)*(cos(k*phi)-1))*exp(-(1/2)*sigma^2*k^2)-(1/5*((1/16)*Pi-1/128*I+(3/8*I)*Pi^4+I*Pi^6+(1/2)*Pi^3))*(cos(k*phi)^2+sin(k*phi)^2)*sin(k*phi))*sqrt(2*sqrt((-4*Pi^2-32*Pi^4-1)^2+256*Pi^6)-8*Pi^2-64*Pi^4-2)+(Pi^6+(9/40)*Pi^4+(11/160)*Pi^2-(1/160)*sqrt((-4*Pi^2-32*Pi^4-1)^2+256*Pi^6)*Pi^2+1/320)*(1/4+Pi^2)*((-sin(k*phi)^3+I*cos(k*phi)*sin(k*phi)^2+(-cos(k*phi)^2-1)*sin(k*phi)-I*c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/4)*Pi^4+1/256+(1/64)*sqrt((-4*Pi^2-32*Pi^4-1)^2+256*Pi^6)*Pi^2+(1/128)*Pi*sqrt(2*sqrt((-4*Pi^2-32*Pi^4-1)^2+256*Pi^6)-8*Pi^2-64*Pi^4-2))*(cos(k*phi)^2+sin(k*phi)^2)*(1+(1/(2*Pi)+sin(k*phi))^2)^2);

Then this is my code to do it. The final result of integrating each term in phi will end up in a list called h. The output will be large.

> h:=[];# set up a list h to store the results of integrating the terms in phi

for z in op(A_1) do

s1a := expand(z): s1 := simplify(remove(has, z, psi),size);

s2:=subs(cos(k*phi)=((1-u^2) / (1+u^2)),cos(m*phi)=((1-u^2) / (1+u^2)), sin(k*phi)=((2*u) / (1+u^2)), sin(m*phi)=((2*u) / (1+u^2)),  s1)*1/(1 + u^2);

with(MultiSeries); _EnvExplicit := true; poles1 := singular(s2, u); t1a := map(`@`(rhs, op), [poles1]); p1 := proc (beta,Q,P) options operator, arrow: select(proc (x) options operator, arrow; 0 < Im(evalf(eval(x, [beta = beta, Q = Q, P = P]))) end proc, t1a) end proc; t1 := p1(beta,Q,P); poles2 := []; for i to nops(t1) do u = t1[i]; poles2 := [op(poles2), %] end do; poles := poles2; residues1 := zip(proc (x, y) options operator, arrow; simplify(x*(lhs-rhs)(y)) end proc, `~`[convert](`~`[MultiSeries:-series](s2, poles, 1), polynom), poles);

residue_total1 := 0;

for i to nops(residues1) do residue_total1 := simplify(residue_total1 + residues1[i], size) end do;

result1 := simplify(((2*Pi*I)*residue_total1),size);

h:=[op(h),result1];

> end do;

p1 above selects the poles with positve imaginary parts.

﻿