[R] Adding "sum" to derivatives table
Rolf Turner
rolf at math.unb.ca
Thu Aug 4 21:13:53 CEST 2005
Martin C. Martin wrote:
> Rolf Turner wrote:
>
> >> deriv(expression(sum(x)), "x")
> >>
> >>
> >
> > does not make any sense.
> >
> >
> Good point. But this does:
>
> deriv(expression(sum(log(a*x))), "a")
>
> where a is a scalar.
Okay --- I see what you're getting at now.
But I think that to get deriv() to handle expressions
of that sort, i.e for
deriv(expression(sum(log(a*x))), "a")
not to fall over, requires more than ``putting sum in the
derivatives table''. The problem is that ``sum'' is not the
``right sort of function''. Functions that appear in the
derivatives table are (I think --- I am not knowledgable
about this) functions of a single variable, like sin and cos
and log, u.s.w. Whereas sum is a function of arbitrarily
many variables.
What is needed is for deriv() to know the rule that ``the
derivative of a sum is the sum of the derivatives''. This
would require rewriting the code of deriv(). Whether the
required rule could be built into deriv() safely and sensibly
is not clear to me. It might be do-able; I wouldn't want to
try it, but!
cheers,
Rolf Turner
rolf at math.unb.ca
More information about the R-help
mailing list