Symbolic differentiation ("D","deriv", etc.) (PR#1928)
lylek@utk.edu
lylek@utk.edu
Thu, 22 Aug 2002 14:45:47 +0200 (MET DST)
Full_Name: Lyle W. Konigsberg
Version: 1.5.1
OS: Windows
Submission from: (NULL) (160.36.64.99)
I apparently found an error in how "deriv" puts a derivative to the screen
(though the internal representation is correct). Here's what I was doing for a
class example:
> lnlk<-expression(15*log(p)+11*log(1-p))
> p<-15/26
> D(D(lnlk,"p"),"p")
-15 * (1/p^2) + 11 * (1/(1 - p)^2)
> eval(D(D(lnlk,"p"),"p"))
[1] -106.5212
> -15 * (1/p^2) + 11 * (1/(1 - p)^2)
[1] 16.38788
>From S+ I have the following:
> lnlk<-expression(15*log(p)+11*log(1-p))
> p<-15/26
> D(D(lnlk,"p"),"p")
- (15 * 1/p^2 + 11 * 1/(1 - p)^2)
> - (15 * 1/p^2 + 11 * 1/(1 - p)^2)
[1] -106.5212
R seems to be dropping the outer parentheses.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._