TO SOLVE AN INTEGRAL WHERE A FUNCTION CONTAINS A COMPLEX SUM
Mostrar comentarios más antiguos
Hello! I am stuck up with a problem where my function contains a sum of certain quantities indeed matrices and scalars that are computed in a loop. The matrices are 2 by 2.
delta=0.75;
for i=2:n
APHNEW=expm([(i-1).*H,(i-1).*(2*(Q'*Q));(i-1).*(R+M),(i-1).*(-(H'))]);
APHNEW11=APHNEW(1:2,1:2); %That is good
APHNEW21=APHNEW(3:4,1:2);
APHNEW12=APHNEW(1:2,3:4);
APHNEW22=APHNEW(3:4,3:4);
BPHNEW22=inv(APHNEW22);
PSIi=BPHNEW22*APHNEW21;
SPSI1=SPSI1+PSIi;
PHIi=beta*(log(det(APHNEW22))+(i-1)*trace(H'))/2;
S0i(i)=exp(-((rbar+mubar)*(i-1)+PHIi));
S0i2(i)=(-((rbar+mubar)*(i-1)+PHIi));
Yn0=Yn0+S0i2(i);
fun0=@(Gamma) exp(trace(1i*(THETA1*inv(eye(2)-2i*SIGMA*Gamma)*SIGMA*Gamma)))/((det(eye(2)-2i*SIGMA*Gamma))^(beta/2));
%In the next line Gamma1 is a scalar and is indeed the parameter
%of the Fourier Transform
%the next two lines are separate functions
fun1 = @(Gamma1) exp((1i*Gamma1+delta)*Yn0)*S0i(i)*fun0(1i*PSIi-(Gamma1-1i*delta)*SPSI);
fun3 = @(Gamma1) exp((1i*Gamma1+delta)*Yn0)*(S0i(i)*fun0(1i*PSIi-(Gamma1-1i*delta)*SPSI)-K*fun0(-(Gamma1-1i*delta)*SPSI));
end
I need to compute fun1 on sum of
S0i(i)*fun0(1i*PSIi-(Gamma1-1i*delta)*SPSI);
and then use this in fun3 which I am writing without sum.
I then use it to define a new function which I have to integrate using quadgk between 0 to infinity. However I am not being able to sum the arguments since Gamma1 is unknown and used in quadgk.
Any help would be great.
Thanks
Warm regards,
5 comentarios
RB
el 14 de Mayo de 2017
Jan
el 14 de Mayo de 2017
@RB: I do not get what you are asking for. Why do you define fun0 inside the loop? As far as I can see, it does not depend on the loop at all.
Currently PHIi is overwritten in each iteration. If you want to store it in a separate array, just store it in a separate array:
PSIi = cell(1, n)
for i=2:n
...
PSIi{i} = ...
fun1 and fun3 are overwritten also.
Some other hints: Using indices in the names of variables is usually a bad idea. Idnices are hidden there and it is more direct to ise indices instead. inv(A)*b is less efficient and accurate as A\b.
RB
el 14 de Mayo de 2017
RB
el 14 de Mayo de 2017
RB
el 16 de Mayo de 2017
Respuestas (0)
Categorías
Más información sobre Gamma Functions en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!