Update:
Somehow, I think I can determine the pole location (even I am not really sure whether it works for any arbitrary input H, c and z). For example, I put some value: H = 100 ; alpha = 0.1019 , z = c = -1; and I can determine the pole location by:
f = @(S) S.*sinh(S.*H)- alpha.*cosh(S.*H);
Pole = fzero(f,alpha);
For the integral, I calculate them by:
fun =@(S)(2.*(S+alpha).*exp(-S.*H).*cosh(S.*(H+c)).*cosh(S.*(H+z)))./((S.*sinh(S.*H))-(alpha.*cosh(S.*H)))
LeftPart = integral(fun,0,Pole);
RightPart = integral(fun,(Pole+(realmin)),7);
Results = LeftPart+RightPart;
The problem here is about the determination of the integral for the RightPart.
- First problem, I use (Pole+realmin) to exclude the singularity which seems to be too tight tolerance. Maybe I can just increase the tolerance ☹.
- Second problem, After S = 7 (somewhere around 7.2), my denominator becomes infinite due to the hyperbolic function (because reaching the maximum floating-point value) and subsequently my nominator as well (even not in the same time). This fact gives NaN results since inf/inf = NaN . Therefore, if I use upper limit of integration for the RightPart as inf (instead of 7), the results of the integration will gives NaN. Even actually the integrand is convergence. That is the reason why I put 7 as my upper limit of integration of the RightPart.
Any idea to avoid the inf/inf due to the hyperbolic function? I feel like its kind of pity to loss the accuracy just because of this since the integrand is converge. And considering the fact that I will have various input for H c and z.
Any idea everyone? Thank you very much!
Regards,
Fredo Ferdian