Dear R users, I would like to express a function (with only one argument) as the integrate of its derivate. For example, for y=x^2, I would like something like integrate(deriv(~x^2,"x", function(x) NULL, formal=T),0,2) which would give me... 4. Thank you, Tristan ---------------------- ?cole Nationale V?t?rinaire d'Alfort - http://www.vet-alfort.fr, T?l. 01 43 96 70 33 M?l. tlorino at vet-alfort.fr Site personnel : http://daedale.free.fr -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help 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-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Deriv and integrate
2 messages · tlorino@vet-alfort.fr, Thomas Lumley
On Thu, 4 Jul 2002 tlorino at vet-alfort.fr wrote:
Dear R users, I would like to express a function (with only one argument) as the integrate of its derivate. For example, for y=x^2, I would like something like integrate(deriv(~x^2,"x", function(x) NULL, formal=T),0,2) which would give me... 4.
integrate(function(x) attr(deriv(~x^2,"x", function(x) NULL, formal=T)(x), "gradient"),0,2) will do it. The deriv() function is designed to produce derivatives for optimisers, which is why it returns the function value with the derivative as an attribute. This does seem a strange thing to want to do... -thomas -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help 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-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._