polygamma(x [,n]), x REAL with positive elements or a structure with REAL components with positive elements, integer n >= 0 |

polygamma(x,0) and polygamma(x) both return the digamma function (first derivative of log(gamma(x))) of the elements of x, when x is a REAL scalar, vector, matrix or array with positive elements. The result has the same shape as x. You can use digamma(x) instead. polygamma(x, n), where n > 0 is an integer returns the n-th derivative of the digamma function ((n+1)-th derivative of log(gamma(x))). polygamma(x, n, scale:T) returns (-1)^(n+1)*n!*polygamma(x,n). For n >= 1, polygamma(x, n, scale:T) = sum((x+k)^(-n-1),k=0,1,2,...,oo). In particular, polygamma(1,n,scale:T) computes zeta(n+1), where zeta(s) is the Riemann Zeta function. When x is a structure, all of whose non-structure components are REAL with positive elements, polygamma(x [,n] [,scale:T]) returns a structure of the same shape and with the same component names as x with each non-structure component transformed by polygamma(). polygamma(x, n) can also be used when x is a CHARACTER variable and n, if present, is a quoted string or CHARACTER scalar or REAL scalar. The result is a CHARACTER variable of the same shape as x describing the transformation. See example below. Any element of x that is "" or starts with '@', '(', '[', '{', '<', '/' or '\' is not modified. This can be useful for creating labels for a transformed variable. Examples: Cmd> polygamma(run(10)) # or polygamma(run(10),0), or digamma(run(10)) (1) -0.57722 0.42278 0.92278 1.2561 1.5061 (6) 1.7061 1.8728 2.0156 2.1406 2.2518 Cmd> polygamma(run(1,2,.25),1) # trigamma (1) 1.6449 1.1973 0.9348 0.7641 0.64493 Cmd> polygamma(vector("x","y"),3) # or polygamma(vector("x","y"),"3") (1) "polygamma(x,3)" (2) "polygamma(y,3)" Cmd> print(nsig:17,polygamma(1,23,scale:T),name:"zeta(24)") zeta(24): (1) 1.0000000596081891 See also digamma(), lgamma(), 'transformations'.

Gary Oehlert 2003-01-15