From: Berend Hasselman <bhh_at_xs4all.nl>

Date: Thu, 21 Feb 2008 12:15:54 -0800 (PST)

Date: Thu, 21 Feb 2008 12:15:54 -0800 (PST)

Chris Rhoads wrote:

*>
**>
*

> I wish to find the root of a function of two variables that is defined by

*> an integral which must be
**> evaluated numerically.
**>
**> So the problem I want to solve is of the form: Find k such that f(k)=0,
**> where f(y) = int_a^b
**> g(x,y) dx. Again, the integral
**> involved must be done numerically.
**>
**>
*

g <- function(x,p) 2*(x-p)

Find value of p such that integral_0^1 g(x,p)dx is zero

f <- function(p) integrate(g,0,1,p)$value

$root should be 0.5 which is what is expected here.

Berend Hasselman

-- View this message in context: http://www.nabble.com/numerical-integration-of-a-ftn-of-2-variables-tp15578652p15618830.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help_at_r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.Received on Thu 21 Feb 2008 - 20:31:07 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Thu 21 Feb 2008 - 21:30:16 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*