From: Naeem Abbasi on 28 Apr 2010 15:24 I am new to MATLAB and have a problem I need help with. I am writing an optimization program. It uses GAMMA function. The argument of gamma function can get as large as 500. MATLAB assumes it to be Inf (i.e., gamma(500)), and because of this I run into problems. how can I avoid this problem? Also I have terms in my expressions which are of type A^b, where both A and b are real numbers. The values of both A and b can be any where between 0 and 200. Is there a way to increase the dynamic range and precision in MATLAB so that I can evaluate numbers such as 200^200? I dont care if takes longer to run, as long as it is able to compute the results I will be happy. Can some please help. Thanks again Naeem
From: Walter Roberson on 28 Apr 2010 15:38 Naeem Abbasi wrote: > I am new to MATLAB and have a problem I need help with. > > I am writing an optimization program. It uses GAMMA function. The > argument of gamma function can get as large as 500. MATLAB assumes it to > be Inf (i.e., gamma(500)), and because of this I run into problems. how > can I avoid this problem? Hmmm, GAMMA(500) is 1132 digits. > Also I have terms in my expressions which are of type A^b, where both A > and b are real numbers. The values of both A and b can be any where > between 0 and 200. Is there a way to increase the dynamic range and > precision in MATLAB so that I can evaluate numbers such as 200^200? 200^200 is 461 digits > I > dont care if takes longer to run, as long as it is able to compute the > results I will be happy. Some of what you want to do can be handled by the multiprecision FEX contribution, but I don't know if it handles GAMMA (maybe it does.) The usual way to handle numbers like this is to use the symbolic toolbox, or to use Maple or Mathematica or equivalent.
From: Steven Lord on 28 Apr 2010 23:02 "Naeem Abbasi" <notnaeemabbasi(a)gmail.com> wrote in message news:hra20k$5q0$1(a)fred.mathworks.com... >I am new to MATLAB and have a problem I need help with. > > I am writing an optimization program. It uses GAMMA function. The argument > of gamma function can get as large as 500. MATLAB assumes it to be Inf > (i.e., gamma(500)), and because of this I run into problems. how can I > avoid this problem? You could try working with the logarithm of the gamma function by using GAMMALN. http://www.mathworks.com/access/helpdesk/help/techdoc/ref/gamma.html > Also I have terms in my expressions which are of type A^b, where both A > and b are real numbers. The values of both A and b can be any where > between 0 and 200. Is there a way to increase the dynamic range and > precision in MATLAB so that I can evaluate numbers such as 200^200? I dont > care if takes longer to run, as long as it is able to compute the results > I will be happy. You will need to use Symbolic Math Toolbox or a similar arbitrary precision package. Note, though, that all the Optimization Toolbox functions expect the objective functions you pass into them to return double precision values; so even if you use Symbolic Math Toolbox to perform your calculations your results will still need to be double precision. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
|
Pages: 1 Prev: Kernel Density Estimation Question Next: bluring an image with 1D FIR filter |