>>>>> "UweL" == Uwe Ligges <[EMAIL PROTECTED]> >>>>> on Tue, 31 Jul 2007 12:13:45 +0200 writes:
UweL> francogrex wrote: >> Hi, 2 questions: [....] >> Question 2: >> >>> deriv(~gamma(x),"x") >> >> expression({ >> .expr1 <- gamma(x) >> .value <- .expr1 >> .grad <- array(0, c(length(.value), 1), list(NULL, c("x"))) >> .grad[, "x"] <- .expr1 * psigamma(x) >> attr(.value, "gradient") <- .grad >> .value >> }) >> >> BUT >> >>> deriv3(~gamma(x),"x") >> Error in deriv3.formula(~gamma(x), "x") : Function 'psigamma' is not in the >> derivatives table >> >> What I want is the expression for the second derivative (which I believe is >> trigamma(x), or psigamma(x,1)), how can I obtain that? UweL> By using some algebraic software (rather than a numeric one) or UweL> contributing complete derivatives tables for the next R release. Yes, but for the present case, one could argue that the R internal code which "knows" d/dx lgamma(x) = psi(x) = digamma(x) = psigamma(x,0) should easily be enhanced to also "know" d/dx psigamma(x, n) = psigamma(x, n+1) and consequently (but maybe with an extra clause) d/dx psigamma(x) = psigamma(x, 1) The code is in R*/src/main/deriv.c and patches which implement the above and (there are few more 'FIXME's there ... ;-) against https://svn.r-project.org/R/trunk/src/main/deriv.c are welcome - after useR!2007 Martin Maechler, ETH Zurich ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.