在R中找到没有封闭形式的积分方程组的根

Finding roots of a system of Integral equations with no closed forms in R

我能够求解单个积分方程的根,并且能够弄清楚如何求解一个简单的方程组,但我正在努力将这两个概念放在一起以求解一个更复杂的方程组.

我想使用使用 rootSolve 库的 MultiRoot 函数。


library(rootSolve)

a11 <- 1 #alpha_{11}
a12 <- 1 #alpha_{12}
a21 <- 1 #alpha_{21}
a22 <- 1 #alpha_{22}
b1 <- 2  #beta1
b2 <- 2 #beta2
d1 <- 1 #delta1
d2 <- 1 #delta2
g <- 0.5 #gamma

#defining the functions
integrand1 <- function(x,S) {b1*g/d1*exp(-g*x)*(1-exp(-d1* x))*exp(-a11*b1*S[1]/d1*(1-exp(-d1*x))-a12*b2*S[2]/d2*(1-exp(-d2*x)))}
integrand2 <- function(x,S) {b2*g/d2*exp(-g*x)*(1-exp(-d2* x))*exp(-a22*b2*S[2]/d2*(1-exp(-d2*x))-a21*b1*S[1]/d1*(1-exp(-d1*x)))}

#defining equation we would like to solve
intfun1<- function(S) {integrate(function(x)integrand1(x, S),lower=0,upper=Inf)[[1]]-1}
intfun2<- function(S) {integrate(function(x)integrand2(x, S),lower=0,upper=Inf)[[1]]-1}

#putting both equations into one term
model <- function(S) c(F1 ​= intfun1,F2 = intfun2)

#Using multiroot to solve
(ss <- multiroot(f = model, start = c(0,0)))

给我以下错误:

Error in stode(y, times, func, parms = parms, ...) : REAL() can only be applied to a 'numeric', not a 'list'


正在努力做到这一点: 我能够求解单个积分方程(在帮助下)

a <-0.3 #alpha
b <- 2.5 #beta
d <-0.7 #delta
g <-1.1 #gamma

#defining the function, note S is free
integrand <- function(x,S) {b*g/d*exp(-g*x)*(1-exp(-d* x))*exp(-a*b*S/d*(1-exp(-d*x)))}

#defining equation we would like to solve
intfun<- function(S) {integrate(function(x)integrand(x, S),lower=0,upper=Inf)[[1]]-1}

#integrating the function from 0 to infinity
uniroot(intfun,c(0,1))

而且我能够弄清楚如何求解一个简单的方程组:

model <- function(x) c(F1 = x[1]+ 4*x[2] -8,F2 = x[1]-4*x[2])
(ss <- multiroot(f = model, start = c(0,0)))

我也尝试用 S1 和 S2 而不是 S[1]、S[2] 来定义代码,但后来我不确定如何使用多根函数,即定义我所有的变量然后

#defining the functions
integrand1 <- function(x,S1,S2) {b1*g/d1*exp(-g*x)*(1-exp(-d1* x))*exp(-a11*b1*S1/d1*(1-exp(-d1*x))-a12*b2*S2/d2*(1-exp(-d2*x)))}
integrand2 <- function(x,S1,S2) {b2*g/d2*exp(-g*x)*(1-exp(-d2* x))*exp(-a22*b2*S2/d2*(1-exp(-d2*x))-a21*b1*S1/d1*(1-exp(-d1*x)))}

#defining equation we would like to solve
intfun1<- function(S1,S2) {integrate(function(x)integrand1(x, S1,S2),lower=0,upper=Inf)[[1]]-1}
intfun2<- function(S1,S2) {integrate(function(x)integrand2(x, S1,S2),lower=0,upper=Inf)[[1]]-1}

#putting both equations into one term
model <- function(S1,S2) c(F1 ​= intfun1,F2 = intfun2)

#Using multiroot to solve
(ss <- multiroot(f = model, start = c(0,0)))

但这给出了同样的错误。我也希望对求解器施加约束,使其仅给出大于 0 的 S 值。谢谢!

integrand1 <- function(x,S) {b1*g/d1*exp(-g*x)*(1-exp(-d1* x))*exp(-a11*b1*S[1]/d1*(1-exp(-d1*x))-a12*b2*S[2]/d2*(1-exp(-d2*x)))}
integrand2 <- function(x,S) {b2*g/d2*exp(-g*x)*(1-exp(-d2* x))*exp(-a22*b2*S[2]/d2*(1-exp(-d2*x))-a21*b1*S[1]/d1*(1-exp(-d1*x)))}

#defining equation we would like to solve
intfun1<- function(S) {integrate(function(x)integrand1(x, S),lower=0,upper=Inf)[[1]]-1}
intfun2<- function(S) {integrate(function(x)integrand2(x, S),lower=0,upper=Inf)[[1]]-1}

#putting both equations into one term
model <- function(S) intfun1(S)**2+ intfun2(S)**2
optim(c(0,0), model) # Note that different initial values(starting points) will produce diff results
$par
[1] 0.06287756 0.11885586

$value
[1] 1.45155e-09

$counts
function gradient 
      37       NA 

$convergence
[1] 0

$message
NULL