R-alpha: D()
Ross &
ihaka@stat.auckland.ac.nz
Wed, 16 Apr 1997 02:23:06 +1200
Thomas Lumley writes:
>
> D() doesn't handle exp() correctly:
>
Duh! Back to first year calculus for me. It's
NOT
d/dx e^f(x) = f(x) * f'(x).
BUT
d/dx e^f(x) = e^f(x) * f'(x).
Deep down in the C function "D" in deriv.c you will find the lines
else if(CAR(expr) == ExpSymbol) {
ans = simplify(TimesSymbol,
CADR(expr),
PP(D(CADR(expr), var)));
UNPROTECT(1);
}
These should in fact read
else if(CAR(expr) == ExpSymbol) {
ans = simplify(TimesSymbol,
expr,
PP(D(CADR(expr), var)));
UNPROTECT(1);
}
I.e. remove the CADR from around the "expr" in the call to simplify.
This has clearly not been tested by anyone with a firm grasp of the
Newton/Leibnitz version of the calculus. Use with care ...
Ross
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
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
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-