I would like to solve a double integral in R of the following form:
where:
b0= function(time){0.05*sin(0.1*time)+0.14}
bi=function(time){0.05*sin(0.1*time)+0.12}
It is a quite complicated equation and I'm not sure if I am solving it in the proper way.
Here is what I`ve tried:
I`ve divided the equation in small parts:
wi<-Vectorize(function(n,t,bi,di){di-bi(n+t)},"n")
InnerIntegral = function(tau,t,bi){
0.1*exp(integrate(wi,lower=0,upper=(tau),t=t,bi=bi,di=0.1)$value)
}
Pext<-function(t,bi,Text){
integrate(Vectorize(InnerIntegral,c('tau')),lower=0,upper=Text-t,t=t, bi=bi)$value
}
PrIntegral<-Vectorize(function(t,b0,bi,Text){
b0(t)*(1-Pext(t,bi=bi,Text=Text))
},"t")
#For T=100
T=100
integrate(Vectorize(PrIntegral,'t'),lower=0,upper=T,b0=b0,bi=bi,Text=100)$value
This gives me -27.77913, but I'm not sure if it is ok. Someone with experience using integrate in R could help me please? Maybe I'm interpreting in the wrong way the equation...
Thanks!