Different answers for the result of integration and summation
1 view (last 30 days)
Show older comments
Hello. I'd like to get the result of this expression for k=1 and m=1
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/191692/image.jpeg)
I prepared the simple code
function z=self_energy1
t=-0.000689609;
T_c=0.242731;
mu=0.365908;
k=1;
N=-1000:1000;
nn=10^4;
fun1=@(a,q) a.*tanh((a.^2-mu)/(2*T_c)).*log((2*a.^2+2*a*q+q^2-2*mu-1i*2*pi*N*T_c)./(2*a.^2-2*a*q+q^2-2*mu-1i*2*pi*N*T_c))/q-2;
fun2=@(q) t+integral(@(a)fun1(a,q),0,nn,'AbsTol',1e-6,'RelTol',1e-3,'ArrayValued',true);
fun3=@(q,m) T_c*q/k*log((-k^2+2*k*q-q^2+mu+1i*2*pi*N*T_c-1i*(2*m+1)*pi*T_c)./(-k^2-2*k*q-q^2+mu+1i*2*pi*N*T_c-1i*(2*m+1)*pi*T_c));
fun4=@(q,m) fun3(q,m)/fun2(q);
S=@(q,m) sum(fun4(q,m));
y1=integral(@(q)S(q,1),0.0001,nn,'AbsTol',1e-6,'RelTol',1e-3,'ArrayValued',true)
end
but the final result depends the point in the function4, i.e. if I set point fun4=@(q,m) fun3(q,m)./fun2(q) then I have one result and if no point there fun4=@(q,m) fun3(q,m)/fun2(q) I get another answer.
Could you tell me what is the correct syntax for the evaluating this expression? Thank you in a advance for your help.
2 Comments
Aquatris
on 6 Jul 2018
The dot division is element-wise division, meaning i th element of the first matrix is divided by i th element of the second matrix. If there is no dot, it is a matrix division. In your case, I think you need the dot division since you need to evaluate the expression seperatly for each q and N values.
Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!