R-alpha: D()

Ross Ihaka ihaka@stat.auckland.ac.nz
Wed, 16 Apr 1997 08:16:23 +1200 (NZST)


	R> D(expression(z * (log(z) /z)),"z")
	Error: invalid form in unary minus check

Yep. this is the result of an implete "if" statement in the C function
"isUminus" in deriv.c.  The function should read

static int isUminus(SEXP s)
{
	if(TYPEOF(s) == LANGSXP && CAR(s) == MinusSymbol) {
		switch(length(s)) { 
		case 2:
			return 1;
		case 3:
			if(CADDR(s) == R_MissingArg)
				return 1;
			else return 0;
		default:
			error("invalid form in unary minus check\n");
		}
	}
	else return 0;
}

This now gives

	> D(expression(z * (log(z) /z)),"z")
	(log(z)/z) + z * (1/z/z - log(z)/z^2)

which I thought was pretty ugly, but

	S-PLUS : Copyright (c) 1988, 1996 MathSoft, Inc.
	S : Copyright AT&T.
	Version 3.4 Release 1 for Sun SPARC, SunOS 4.1.3_U1 : 1996
	Working data will be in .Data
	> D(expression(z * (log(z) /z)),"z")
	(log(z)/z) + z * (1/z/z - log(z)/z^2)

So we are no worse than S.

And shame on you for trying to fool such a dumb bit of software :-).
	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
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-