Code covered by the BSD License  

4.1 | 25 ratings Rate this file 52 Downloads (last 30 days) File Size: 139 KB File ID: #6218

Computation of Special Functions


Ben Barrowes (view profile)


09 Nov 2004 (Updated )

MATLAB translation (via f2matlab) of the original FORTRAN of "Computation of Special Functions."

| Watch this File

File Information

MATLAB routines for computation of Special Functions

These routines are a direct translation, performed using f2matlab, of the original FORTRAN-77 implementation of "Computation of Special Functions."

For detailed description of the algorithm of each program, please consult the book "Computation of Special Functions."
Also see Errata at:

Bernoulli numbers
Euler numbers
Chebyshev, Laguerre, and Hermite polynomials
Gauss-Legendre quadrature
gamma function.
logarithm of the gamma function.
gamma function with a complex argument.
beta function.
psi function.
psi function with a complex argument.
incomplete gamma function.
incomplete beta function.
Legendre polynomials
Legendre functions of the second kind
associated Legendre polynomials
Bessel functions of the first and second kinds
zeros of the Bessel functions of the first and second kinds
lambda functions
modified Bessel functions of the first and second kinds
Hankel functions of the first and second kinds
integral of Bessel functions J0(t) and Y0(t) from 0 to x
integral of [1-J0(t)]/t from 0 to x and Y0(t)/t from x to infinity
integral of modified Bessel functions I0(t) and K0(t) from 0 to x
integral of [1-I0(t)]/t from 0 to x and K0(t) from x to infinity
spherical Bessel functions of the first and second kinds
Riccati-Bessel functions of the first kind and second kind
modified spherical Bessel functions of the first kind and second kind
Kelvin functions
zeros of the Kelvin functions
Airy functions
integral of the Airy functions.
zeros of Airy functions
Struve functions with an arbitrary order
integral of Struve function H0(t) from 0 to x.
integral of H0(t)/t from x to infinity.
modified Struve function with an arbitrary order.
integral of modified Struve function L0(t) from 0 to x.
hypergeometric function
hypergeometric function M(a,b,z)
hypergeometric function U(a,b,x)
parabolic cylinder functions Dv(z)
parabolic cylinder functions Vv(x)
parabolic cylinder functions W(a,+/-x)
characteristic values for the Mathieu and modified Mathieu functions.
expansion coefficients for the Mathieu and modified Mathieu functions.
Mathieu functions
modified Mathieu functions of the first and second kinds
characteristic values for spheroidal wave functions.
angular spheroidal wave functions
radial spheroidal wave functions
error function.
Fresnel Integrals.
modified Fresnel integrals.
complex zeros of the error function.
complex zeros of the Fresnel Integrals.
cosine and sine integrals
complete and incomplete elliptic integrals of the first and second kinds.
complete and incomplete elliptic integrals of the third kind.
Jacobian elliptic functions.
exponential integral E1(x)
exponential integrals En(x)
exponential integral Ei(x)


This file inspired Generation Of Random Variates, Impulsive Noise Meter, Continuous Sound And Vibration Analysis, Confluent Hypergeometric Function (Kummer Function), and Fresnel S And Fresnel C.

MATLAB release MATLAB 7.0.1 (R14SP1)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (33)
08 Aug 2014 HAI

HAI (view profile)

I believe it very useful, but how I can get the collection?

23 May 2012 Marzieh  
23 May 2012 Marzieh

Great job,Really nice!

Comment only
29 Feb 2012 Beijing Jiaotong University


12 Jan 2012 David Holdaway

while useful these are extremely hard to read functions. I have been having problems with mchgu for vectorised inputs. This appears to be due to the logic choices for high and low arguments not working for vectorised x.

For instance
mchgu(11,1/2,[-100,100]) =
1.0e-21 *[-0.4281 0.0320]
gives the correct answer, where as
mchgu(11,1/2,[-100,0,100] =
1.0e+46 * [5.3505 - 4.4981i 0.0000 -4.9590 ]
is wrong by many many orders of magnitude.
Essentially it works fine for single arguments but not vectors.

18 Dec 2011 shahin Eskandari  
23 Nov 2010 MLM

MLM (view profile)

I tried the Associated Legendre Function for complex arguments and it is helpful, thanks.
But it seems to have a little flaw. When displaying the calculated values, it just displays only the real part of the answer, although the answer is complex. It might be helpful if you alter it, so that others can use it without checking it. Please let me know, if I have missed or misunderstood anything regarding that answer being complex.
Anyway Great work.

Comment only
19 Jan 2010 Chih-Ying Hsiao

helpful! Thanks!

29 Sep 2009 Chamane


04 May 2009 Dorra

Dorra (view profile)

very helpful but i have a little bit difficulty to find the function i need

14 Dec 2008 Da Ma

Da Ma (view profile)

very useful and good work!

Comment only
12 Jul 2008 yogendra prajapati

I cannot understand how to use derivative of modified Mathieu function first and second kind.any one tell me.

Comment only
20 Mar 2008 Ellips Wang

Mathieu angle function is not correct. How to correct it? Thank you. I also need the spheroidal function.

27 Sep 2007 Eduardo Kausel

This collection of special mathematical functions originated in Fortran programs by S. Zhang & J. Jin, which accompany their book "Computation of Special Functions" (Wiley, 1996). The Matlab versions are direct machine conversions of the Fortran sources via an automatic translation program.

These functions provide a valuable base from which to build a useful library of advanced mathematical functions, but users should exercise caution in their use. First, the machine translations are not particularly pretty, for the code has no indented nested statements, and none of the routines is vectorized (i.e. vector arguments, loops, initializations, and the like). Also, the code is chock-full with “magic” numbers at the local level of the statements (decision flags, transition values, etc) that are neither explained nor defined. Furthermore, the codes are completely devoid of comments, and all input arguments are needlessly returned as output arguments. In summary, these functions constitute so-called spaghetti code.

More importantly --and unfortunately-- the routines are also rather buggy and suffer from miscellaneous intrinsic errors. For example, the code for Struve functions gives erroneous values for complex and negative numbers. This is because no careful attention was paid to analytic continuation relations in the complex plane. In my work, I have used several of these functions, and in every case I have found errors of some sort. Thus, every time I adopt one of these functions for some purpose, I begin by closely examining in detail what it does (the Handbook of Mathematical Functions by Abramovitz and Stegun is an invaluable resource for this purpose), completely re-writing the code in good Matlab style (including indentation, vectorization and comments) and then thoroughly checking the results for a range of values (small, large, complex, negative, integers, etc). You should do the same.

20 Sep 2007 sepp sepp

Many of the functions do not work.
see for example mclqn.m
The reason herefore is the conversion
from fortran code. Would be nice if the author could try the conversion once again with a newer version of f2matlab

30 Aug 2007 Quan Hieu Huynh

It is helpful, but incomplete. Have you done a Meijer G function? If yes, please send it to me. I need it.
Thank you a lot.

Comment only
15 Aug 2007 Nicolas Marchand

Essential !

22 May 2007 arthur cao

great!thanks a lots.

08 Mar 2007 adem mellekh


06 Sep 2006 jason tharmaraj

it is very interesting for beginers and very useful

10 Aug 2006 Igor Moiseev

The package has to be improved. The multidimensional arrays support should be added. For elliptic function please consult mine subscription. If you have any idea about it, please concact me.

23 May 2006 sajida malik

it will be helpful

15 May 2006 Ellips Wang

I tested spheroidal functions and found that mrswfp.m mrswfo.m didn't work correctly changing the values of parameters. Though I tried to the errors, the results I got had low precision especially with the small parameter. How to correct the errors, and improve the precision? Thank you very much!

26 Apr 2006 Joan Baiges

I used only the gauss laguerre and gauss hermite quadratures. The functions calculate everything correctly but do not return the values. They only require a little modification and they work correctly (you can specify the number of points of integration and the function returns the vector correctly calculated).

23 Mar 2006 Sumeet Gupta

Can anyone please tell me the that routine MTU12 which is used for calculating modied Mathieu functions of first and second kind also works for complex arguments (to be specific for complex q).
Also does it take into account the change in functions from radial to evanescent radial functions as q moves from positive to negative values. By this point I mean that does it take into account the fact that different second kind functions are evaluated when q is negative or positive

11 Feb 2006 bruining hans

Cnnot be immediately unpacked

Comment only
28 Dec 2005 John Wu

Great work!! Thanks!!

24 Dec 2005 hafedh gaha  
06 Dec 2005 Juan Pablo Carbajal

I was looking for the half-integer legendre functions of the second kind but this pack has the hypergoemetric function, that should be enough. Thanks!

05 Dec 2005 Abdul Mufid

i need this software for my research

Comment only
24 Aug 2005 zubin jacob

can someone tell me if the mathieu function works for high orders? i found that it doesn't

07 Jun 2005 bibhuti sahu

Dear Sir,
i do not know whether it is suitable for large argument to bessel functions (of first and second kind) with complex argument.

your suggestion regarding this will most welcome.

Comment only
20 Jan 2005 li wang

i don ont know whether it is suitable for large argument to gamma function with complex argument

16 Nov 2004

spelling fix in description

05 Jan 2005

Updated conversion.

28 Jan 2005

new keywords

12 Apr 2005

Modified decription

Contact us