Double integration with a differentiation inside in R

66 Views Asked by At

I need to integrate the following function where there is a differentiation term inside. Unfortunately, that term is not easily differentiable.

Is this possible to do something like numerical integration to evaluate this in R?

Function to integrate You can assume 30,50,0.5,1,50,30 for l, tau, a, b, F and P respectively.

UPDATE: What I tried

InnerFunc4 <- function(t,x){digamma(gamma(a*t*(LF-LP)*b)/gamma(a*t))*(x-t)}
InnerIntegral4 <- Vectorize(function(x) { integrate(InnerFunc4, 1, x, x = x)$value})
integrate(InnerIntegral4, 30, 80)$value

It shows the following error:

Error in integrate(InnerFunc4, 1, x, x = x) : non-finite function value

UPDATE2:

InnerFunc4 <- function(t,L){digamma(gamma(a*t*(LF-LP)*b)/gamma(a*t))*(L-t)}
    
t_lower_bound = 0
t_upper_bound = 30
L_lower_bound = 30
L_upper_bound = 80
step_size = 0.5
integral = 0

t <- t_lower_bound + 0.5*step_size
while (t < t_upper_bound){
  L = L_lower_bound + 0.5*step_size
  while (L < L_upper_bound){
    volume = InnerFunc4(t,L)*step_size**2
    integral = integral + volume
    L = L + step_size
  }
  t = t + step_size
}
1

There are 1 best solutions below

8
Indiano On

Since It seems that your problem is only the derivative, you can get rid of it by means of partial integration:

enter image description here

Edit Not applicable solution for lower integration bound 0.