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
from Special Functions math library by Paul Godfrey
Collection of Special Functions programs.

genocchi(z)
function [f] = genocchi(z)
%Genocchi number
%      f = Genocchi(n) returns the nth Genocchi number(s)
%      Genocchi(n)=0 for all odd n except 1.
%      Genocchi numbers can be generated from the Taylor
%      expansion of tan(x/2) and can be used (with scaling)
%      anywhere Bernoulli numbers are used. Genocchi numbers
%      are always integers whereas the Bernoulli numbers are not.
%
%      An asymptotic 3 term recurrence relationship is:
%
%                ( 2*G(n)   G(n-2)     8  )
% G(n+2) ~= G(n)*( ------ - ------ - -----)
%                ( G(n-2)   G(n-4)   pi*pi)
%
%
%      The first 216 Genocchi numbers generated by this
%      function are calculated from the Bernoulli numbers.
%      Values for n>216 will probably be larger than
%      REALMAX for your machine.
%      Use the above reccurence relationship for n>216
%
%      n can be any size
%      
%      Usage:  f = Genocchi(n)
%
%      Tested under version 5.3.1
%
%see also BERN, EULER

%Sloane's integer sequence A036968, A001469
 
%Paul Godfrey
%pgodfrey@conexant.com
%July 6, 2000

[row, col]=size(z);
z=z(:);

k = 2*(1-2.^z);

f=k.*bern(z);

p=find(z==1);
f(p)=1;

f=reshape(f,row,col);

return

%to generate these numbers
syms x real
p=taylor(tan(x/2),20);
c=(fliplr(sym2poly(p)))';
f=gamma((1:20)'+1);
s=(-1).^((1:20)/2)';
g=s.*c.*f

Contact us at files@mathworks.com