Re: Erroneous Mathematica Kummer's (Hypergeometric1F1)
- To: mathgroup at smc.vnet.net
- Subject: [mg81486] Re: Erroneous Mathematica Kummer's (Hypergeometric1F1)
- From: sashap <pavlyk at gmail.com>
- Date: Wed, 26 Sep 2007 06:29:58 -0400 (EDT)
- References: <200709240114.VAA01940@smc.vnet.net><fd7rr7$cch$1@smc.vnet.net>
On Sep 24, 3:17 am, Carl Woll <ca... at wolfram.com> wrote: > W. Brenig wrote: > >Hi, > > >This excerpt from a notebook demonstrates that Mathematica's > >implementation of the confluent hypergeometric function is > >erroneous. The integral representation of the Hypergeometric1F1[] > >function is > > >In[115]:= f11[m_, n_, z_] := ((n - 1)!/((n - m - 1)! (m - 1)!)) > > NIntegrate[Exp[ x z] x^(m - 1) (1 - x)^(n - m - 1), {x, 0, 1}]; > > >Now, we use this representation to evaluate f11 for two > >representative sets of parameters > > >In[116]:= f11[5, 106, 10 Pi I] > >Out[116]= 0.101285+ 0.811816 \[ImaginaryI] > > >In[117]:= f11[4.6, 105.3, 10 Pi I] > >Out[117]= 0.190397+ 0.80675 \[ImaginaryI] > > >These values have also been tested to result on use of the > >routine CCHG(A,B,Z,CHG) for the confluent 1F1 hypergeometric > >function, copyrighted to Zhang and Jin, authors of the book > >'Computation of Special Functions', Wiley-Interscience, (1996). > > >Next we use Mathematica's Hypergeometric1F1[] function with > >the same parameters > > >In[121]:= N[Hypergeometric1F1[5, 106, 10 Pi I]] > >Out[121]= -5952. - 2512. \[ImaginaryI] > > >In[122]:= N[Hypergeometric1F1[4.6, 105.3, 10 Pi I]] > >Out[122]= 0.190397+ 0.80675 \[ImaginaryI] > > >Obviously the 1st result is different from f11's value. > >This is only one of many other examples, which show that > >Mathematica's Hypergeometric1F1[] is broken - at least for > >integer value input parameters. > > Actually, Hypergeometric1F1 is working fine. What goes wrong is > evaluating the result of 1F1 with machine numbers. As is typical of > machine numbers when subtracting large numbers, catastrophic loss of > precision occurs. Use extended precision numbers, as in: > > In[463]:= N[Hypergeometric1F1[5, 106, 10 Pi I], 20] > > Out[463]= 0.10128468746141561560+0.81181630676361012768 \[ImaginaryI] > > When using extended precision numbers, Mathematica will internally > generate numbers to higher precision to attempt to get a result with the > requested precision. When using machine numbers, no such significance > tracking is done. > > Alternatively, use at least one machine number as an argument to > Hypergeometric1F1: > > In[464]:= Hypergeometric1F1[5., 106, 10 Pi I] > > Out[464]= 0.101285+0.811816 \[ImaginaryI] > > Carl Woll > Wolfram Research > > >Regards, > >Wolfram Incorrect numerical evaluation occurs because Hypergeometric1F1[5, 106, 10 Pi I] evaluates to much larger expression involving incomplete gamma function. That expression is, then, being evaluated numerically with machine precision. In[24]:= expr = Hypergeometric1F1[5, 106, 10 Pi I]; (* get the exact result *) (* split the sum apart into a list of summands and numerically evaluate each *) In[25]:= N /@ (List @@ expr) Out[25]= {-4.59813*10^6, 0.- 3.13205*10^17 \[ImaginaryI], -3.78448*10^17, 0.+ 1.73145*10^17 \[ImaginaryI], 3.55523*10^16, 0.- 2.76463*10^15 \[ImaginaryI], 0.+ 4.19316*10^6 \[ImaginaryI], 1.29539*10^6, 0.- 135652. \[ImaginaryI], 4.22904*10^6 + 3.13205*10^17 \[ImaginaryI], 3.78448*10^17 - 5.10997*10^6 \[ImaginaryI], -2.33788*10^6 - 1.73145*10^17 \[ImaginaryI], -3.55523*10^16 + 480043. \[ImaginaryI], 37329.2+ 2.76463*10^15 \[ImaginaryI]} as you see scales of these summands are quite different from the scale of result. Subtractions of those large numbers is what is responsible for the incorrect result. In order to avoid such exact evaluation of Kummer confluent hypergeometric function, as Carl pointed out, one of the 1F1's arguments must be inexact: In[28]:= Hypergeometric1F1[5, 106, 10.0 Pi I] Out[28]= 0.101285+0.811816 \[ImaginaryI] Oleksandr Pavlyk Special Functions Developer Wolfram Research
- References:
- Erroneous Mathematica Kummer's (Hypergeometric1F1) function
- From: "W. Brenig" <w.brenig@tu-bs.de>
- Erroneous Mathematica Kummer's (Hypergeometric1F1) function