我试图用包nleqsl解决这个系统,但我没有成功。有人能帮助我吗?
require(nleqslv)
fun<-function(x, E1, V1, E2,V2) {
y <- rep(NA, length(x))
y[1]=E1-(x[1]/x[2]+x[4]*x[1]/x[2]^3)
y[2]=V1-(x[3]/x[2]^2+x[4]*x[1]^2/x[2]^4)
y[3]=E2-(x[2]/x[1]+x[3]*x[2]/x[1]^3)
y[4]=V2-(x[4]/x[1]^2+x[3]*x[2]^2/x[1]^4)
return(y)
}
E1=2.08
V1=0.2
E2=0.505
V2=0.0125
xstart <- c(1, .9, 1,.9)
nleqslv(xstart, fun, E1=E1,V1=V1,E2=E2,V2=V2)
预期答案:x = c(10,5,1,1)
答案:
$x
[1] 13384651 12046186 26769295 24092367
$fvec
[1] 0.96888871 0.19999961 -0.39500014 0.01249974
$termcd
[1] 5
$message
[1] "Jacobian is too ill-conditioned (1/condition=4.7e-018) (see allowSingular option)"
$scalex
[1] 1 1 1 1
$nfcnt
[1] 1
$njcnt
[1] 1
$iter
[1] 2
提前致谢!