Hi,
Could somebody help me with the following. I want to calculate the integral
over an implicit function. I thought to integrate over a function depending on
uniroot. In previous topics I found a thread about finding the root of an
integral. And that works. But the other way around, does not work. Does R
support this?
I included the following example. The function in the example is very easy and
can be solved explicitly, but when it does not work for such an easy function
it will certainly not work for a more difficult function. First the root of an
integral (which works) and then the integral of a function dependent on uniroot:
# Calculating the root of an integral
a<- function(x,y)
{x-y}
b<- function(y)
{integrate(a,lower=1,upper=2,y=y)$value}
d<- uniroot(b,c(0,10))$root
print(d)
# Calculating the integral of a function dependent on uniroot
e<- function(u,v)
{u-v}
f<- function(v)
{uniroot(e,c(0,10),v=v)$root}
g<- integrate(f,lower=1,upper=2)$value
print(g)
Does anyone have suggestions how to proceed? By the way, the implicit function
I am targeting does have a unique solution, it is only not explicitly solvable,
i.e. in the example above, you cannot solve u as a function of v explicitly, so
as to substitute it in the integrand.
Thanks a lot in advance for your help,
Best regards,
Eddy Bekkers
Department of Economics
Erasmus University Rotterdam
______________________________________________
[email protected] 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.