MATLAB: Exp(infty1) * erfc(infty2) = NaN

erfcinfinity

Hi
My problem is that I have the following analytical solution to a flow problem
The meaning of the parameters are as such not relevant to the problem, but the problem arises from the last term of A_i. The solution works perfectly for specific sets of parameters, but for the ones I need it for there is a problem. The exponential goes towards infinity, ~exp(2*10^4), where the complimentary error function goes towards zero, erfc(x) where x is in the interval 140 to infinity (however can MAYBE be limited to the interval of 140-200). How do I handle this? Matlab's limit of doubles seems to be 10^(+-308), which is not nearly enough to solve the problem, where the exp term is approx equal to 10^8685

Best Answer

You have several choices.
1. Use the symbolic Toolbox, which can handle high precision computations.
x = sym(200);
vpa(erfc(x))
ans =
4.6893592959836014980356997769923e-17375
2. Use my HPF toolbox, which can also handle high precision computations. I thought I implemented erfc, but its been a while. It should be doable though. I do know there is what looks like a nicely convergent expansion for large x for erfc. So if it turned out I did not implement erfc for large arguments, it would be pretty easy to write (I think.)
3. Use approximations, numerical analysis, etc. For example, I'd not be surprised if there is not a method to compute the log(erfc(x)), for large x. No matter what, you will still probably need a tool that can provide wide ranging computations on lots of digits, because you are adding terms there. Will you need thousands of significant digits? Or can some terms simply drop out when they are clearly insignificant? Again this is a numerical analysis question as much as anything.
Let me expand on my last comment. If the last term is insignifcant compared to the others, AND you are willing to work in double precision, you would merely compute the log of that last term. A poor approximation for the log of that expression would suffice there to know IF that term is indeed insignificant.
In the end, you will need to be careful and use good numerical methods no matter which approach you take here. Remember that the issue is not only the dynamic range of a double, but the number of significant digits it carries in the mantissa, and how many correct digits you really need in your result.
Related Question