version 1.0.0.0 (37.1 KB) by
Paul Godfrey

Collection of Special Functions programs.

9 Downloads

Updated 26 Aug 2004

No License

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.

Paul Godfrey (2021). Special Functions math library (https://www.mathworks.com/matlabcentral/fileexchange/978-special-functions-math-library), MATLAB Central File Exchange. Retrieved .

Created with
R12

Compatible with any release

**Inspired:**
Generation of Random Variates

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!Create scripts with code, output, and formatted text in a single executable document.

Uiy UiyGetting errors such as

>> zeta(0.4964 + 1.9374*i)

Error using gamma

Input must be real and full.

Error in deta (line 154)

f(L)=t.*cos(pi/2*zz).*gamma(zz).*f(L);

Error in zeta (line 26)

f=k.*deta(z,1);

There seems to be a bug in the code.

Christian IandiorioStefan Rodrigues Sandnerxj wRobert GraggExcellent tools.

MATLAB should have this complex-plane functionality for its built-in erf, gamma, gammaln, and psi.

MartinI mean Paul, sorry.

MartinHey Peter. Does your erfz function still work in version 7.14.0.0739 which i currently have?

Aurelien QueffurustThe totient function to compute euler phi could be written in one line:

phi = arrayfun(@(x) fix(max(1,x*prod(1 - 1./unique(factor(x))))),n)

ScottThe 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!

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

David YoungVery 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.

Ben PetschelNice 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).

andrzej andjez@gazeta.plBart SelinsThis is exactly wat I needed, works perfect

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

Amine AbdallahMarinos VouvakisJoerg EnderleinVery useful!

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

ETOR AMAFUi like your notes

kadir tasPeter TheodossiouVery Useful.

Needs a similar routine for

polygamma.

Laurie MailheThanks, I found it very useful!

teresa pulidovery helpful. thanks! =)

Nikolai Tolichvery useful

asmail KAHDERvery good

asmail KAHDERvery good