3

Octave doesn't seem to have a function to compute the generalized hypergeometric function pFq, or its simpler particular case 2F1:

>> help hypergeom
error: help: the 'hypergeom' function belongs to the symbolic package from Octave
Forge but has not yet been implemented.

Is there some well-known method or some function available in Matlab/Octave for computing pFq or 2F1? Ideally I would like something similar to Matlab's hypergeom, but not necessarily symbolic. It doesn't need to be particularly fast.

Applying the definition in terms of an infinite sum doesn't seem to be a good idea, because it may be numerically unstable.

Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
  • 2
    I'm not terribly familiar with the subject matter, perhaps porting [this FEX submission](http://www.mathworks.com/matlabcentral/fileexchange/5616-generalized-hypergeometric-function) may be a useful start? – sco1 Feb 12 '16 at 01:33
  • 2
    @excaza Thanks! It seems to give reasonably accurate results, also in Octave. Make that an answer? – Luis Mendo Feb 12 '16 at 01:41
  • At best, using the GSL package ( http://octave.sourceforge.net/gsl/) may be your best bet. At worst, the Octave package has not been updated to reference the desired hypergeometric functions in full. Though they certainly exist in GSL, the GSL package for Octave may not necessarily have binds for them. – Zéychin Feb 12 '16 at 01:47
  • while the GSL package hasn't been updated in ages (and is listed as unmaintained by Octave Forge), writing your own function that interfaces with GSL will be pretty simple (provided you're comfortable with C++). So simple that almost all of the functions in the gsl package are generated automatically. – carandraug Feb 12 '16 at 10:33
  • See my [answer on Math.StackExchange](http://math.stackexchange.com/a/480175/80812). As long as you just need the Gaussian hypergeometric function 2F1 in the base regime then [my code](http://biorobots.cwru.edu/personnel/adh/math.se/04/hypergeom2F1.m) should be very easy to port to Octave and fast. – horchler Feb 12 '16 at 17:03
  • 1
    @horchler Thanks! I saw (and upvoted) that answer yesterday – Luis Mendo Feb 12 '16 at 18:30
  • Hm. None of the previously mentioned contributions seems to deal with the |z|>1 regime. I wonder hoy Matlab's `hypergeom` does it – Luis Mendo Feb 12 '16 at 23:17
  • @Luis Mendo: Have you tried the octave-gsl package? As far as I can see all functions described here https://www.gnu.org/software/gsl/manual/html_node/Hypergeometric-Functions.html are implemented – Andy Feb 15 '16 at 10:57
  • @Andy Thanks! But orders above 2 seem to be missing. I ended up using the FEX sumbmission suggested above by excaza, with some modifications – Luis Mendo Feb 15 '16 at 13:17

1 Answers1

1

The Octave-forge GSL package will have hyperg_2F1 in the next release. See buildgsl_sf.sh

Andy
  • 7,931
  • 4
  • 25
  • 45