No BSD License  

Highlights from
Special Functions math library

  • bern(n) Bern Bernoulli number
  • betad(z) BETAD Dirichlet Beta function
  • binomial(n,d) BINOMIAL calculate the binomial coefficient
  • deta(z,k) DETA Calculates Dirichlet functions of the form
  • erfz(zz) ERFZ Error function for complex inputs
  • eta(z) ETA Dirichlet Eta function
  • euler(n) Euler Euler number
  • eulergamma Euler-Mascheroni constant = -Psi(1) = 0.5772156649015328606...
  • fact(n) FACT Vectorized Factorial function
  • factd(n) FACTD Double Factorial function = n!!
  • gamma(z) GAMMA Gamma function valid in the entire complex plane.
  • gammaln(z) GAMMALOG Natural Log of the Gamma function valid in the entire complex plane.
  • genocchi(z) Genocchi number
  • harm(z) Harm Harmonic sum function valid in the entire (complex) plane.
  • lambda(z) LAMBDA Dirichlet Lambda function
  • poch(z,n)
  • psi(z) Psi Psi (or Digamma) function valid in the entire complex plane.
  • psin(n,z) Psin Arbitrary order Polygamma function valid in the entire complex plane.
  • totient(n) TOTIENT calculates the totient function (also
  • zeta(z) ZETA Riemann Zeta function
  • View all files

4.61111

4.6 | 18 ratings Rate this file 35 Downloads (last 30 days) File Size: 37.12 KB File ID: #978

Special Functions math library

by Paul Godfrey

 

23 Oct 2001 (Updated 26 Aug 2004)

Collection of Special Functions programs.

| Watch this File

File Information
Description

A collection of special function programs valid in the entire complex plane. Includes Gamma, loggamma, psi, polygamma, error, zeta, and others.

Editor's Note: Please note that these files have the same names as files already included with MATLAB. Being aware of where they are on your path will help you determine when you're using these files and not the MathWorks versions.

Programs to calculate the complex Gamma, complex LogGamma, complex error, complex psi, complex Riemann zeta, vectorized factorial, vectorized double factorial functions as well as Bernoulli, Euler, Genocchi, and totient numbers.

MATLAB release MATLAB 6.0 (R12)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (19)
05 Jan 2003 asmail KAHDER

very good

05 Jan 2003 asmail KAHDER

very good

11 Jun 2003 Nikolai Tolich

very useful

08 Jul 2003 teresa pulido

very helpful. thanks! =)

15 Aug 2003 Laurie Mailhe

Thanks, I found it very useful!

08 Sep 2003 Peter Theodossiou

Very Useful.
Needs a similar routine for
polygamma.

02 Dec 2003 kadir tas  
14 Mar 2004 ETOR AMAFU

i like your notes

07 Jun 2004 David Terr

Looks great! I haven't even tried most of these yet, but I can tell it's a very useful package.

07 Aug 2004 Joerg Enderlein

Very useful!

06 Sep 2004 Marinos Vouvakis  
13 Jan 2005 Amine Abdallah  
18 May 2005 Jaime Ramirez

Really useful, includes functions that are not easy to find somewhere else

19 Oct 2005 Bart Selins

This is exactly wat I needed, works perfect

24 Jan 2006 andrzej andjez@gazeta.pl  
14 Aug 2011 Ben Petschel

Nice work, these should be included in the core MATLAB.

Since erf rapidly goes to infinity along the i axis (e.g. erfz(1i*30) = 1i*Inf in floating point), it would be useful to have a function that calculates exp(z^2)*erf(z) or z*exp(z^2)*erfc(z).

18 Sep 2011 David Young

Very helpful and useful (rating and comments based only on gamma and gammaln functions). Suggestions:

1. The code to allocate storage:

 f = 0.*z; % reserve space in advance

is not needed (indeed is wasteful), as preallocation is only useful ahead of a loop or to set up an array of a specific shape.

2. It might be worth switching to logical indexing rather than linear indexing - this would avoid the use of find() and the reshape at the end.

3. gammaln(z) returns infinities for abs(imag(z)) greater than about 226 and real(z) < 0. This is due to overflow of sin() in the reflection formula, but it is an unnecessary restriction as log(sin(z)) can be computed without overflow over a larger set of values than can sin(z). For example, we can use log(sin(x + iy)) (x and y real) is approximately equal to y + log(0.5i * exp(-1i * x)) for large positive y, and the approximation is good to machine accuracy if y > 18 or thereabouts. (For negative y the approximation is -y + log(-0.5i * exp(1i * x)).) Replacing log(sin()) by a call to a logsin() function that uses these approximations greatly extends the set of valid arguments.

04 Jan 2012 Bien

Thanks! Needed a erfz function and this works well for me. This should be in the standard MATLAB function.

10 Jan 2012 Scott

The package is generally excellent.
My only complaint is that the accuracy of the zeta function deterioriates rapidly for |z|>80.
For example, the script returns
0.541674252238781 - 0.348243845696725i
for the 29-th non-trivial zero, which is approximately 0.5+98.8311i.
 
If you ever have time for an upgrade it would be much appreciated!

Please login to add a comment or rating.
Updates
26 Aug 2004

Update to my earlier submissions. Adds an arbitrary order complex polygamma function, pochhammer, harmonic sum. Includes complex gamma, loggamma, bernoulli, euler numbers, Riemann zeta, factorial, binomial, and other functions.

Tag Activity for this File
Tag Applied By Date/Time
special functions Paul Godfrey 22 Oct 2008 06:38:50
gamma Paul Godfrey 22 Oct 2008 06:38:50
erf Paul Godfrey 22 Oct 2008 06:38:50
polygamma Paul Godfrey 22 Oct 2008 06:38:50
zeta Paul Godfrey 22 Oct 2008 06:38:50
psi Paul Godfrey 22 Oct 2008 06:38:50
factorial Paul Godfrey 22 Oct 2008 06:38:50
pochhammer Lorenzo 08 May 2010 02:13:44
log gamma David Young 18 Sep 2011 08:01:03
gammaln David Young 18 Sep 2011 08:01:03
zeta Watheq Elias 20 Sep 2011 17:00:30
zeta Didier Clamond 26 Sep 2011 05:05:15
factorial dmitriev mike31bc 13 Mar 2012 11:10:20

Contact us at files@mathworks.com