I am new to R and need some help using integration. I have a function defined as:
a <- function(t) { exp(-r1*t) }
I have another function which uses this function and is defined as:
b <- function(t,x) { a(t-x)* exp(-(1-exp(-r2*x))) }
where, r1
and r2
are constants.
Now, I need to integrate the function b(t,x)
for values of x
that range from 0
to t
; given that x <= t
.
I am not sure how to proceed with this. I tried the following, but I am not sure how to tell R to integrate over 'x' and not 't'.
c <- integrate(b, lower=0, upper=10)
When i run this, I get an error saying:
Error in a(t -x) : argument "t" is missing, with no default
Thanks in advance,
-S