From ihaka@stat.auckland.ac.nz  Tue Apr 15 15:23:06 1997
From: ihaka@stat.auckland.ac.nz (Ross &)
Date: Wed, 16 Apr 1997 02:23:06 +1200
Subject: R-alpha: D()
In-Reply-To: <Pine.SUN.3.95.970414175127.18041A-100000@sulu>
References: <9704090917.AA01943@>
 <Pine.SUN.3.95.970414175127.18041A-100000@sulu>
Message-ID: <199704151423.CAA06246@stat9.stat.auckland.ac.nz>

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
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


R-alpha: D()
Ross &