Different answers for the result of integration and summation

1 次查看(过去 30 天)
Hello. I'd like to get the result of this expression for k=1 and m=1
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 个评论
Aquatris
Aquatris 2018-7-6
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.
Yuriy Yerin
Yuriy Yerin 2018-7-7
Thank you for you response. I know about the meaning of the dot division but I was confused that I got wrong result of this expression obtained earlier by another approach (Fortran). So that's why I decided to ask community in hope that somebody pays attention on my possible mistake. Anyway thanks again.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by