用BB这个包
我的方程组是
x^4 + y^4 + 2 x^2 y^2 - 5 x y = 15
2 x^4 + 5 y^4 + x^3 y - 6 x y^3 = 36
缺点是x和y肯定有很多组解,用这个方法得到的解和你给的初值有关
推荐用Mathematica
- > library(BB)
- >
- > func <- function(x) {
- + n <- length(x)
- + f <- rep(NA, n)
- + f[1] <- x[1]^4+x[2]^4+2*x[1]^2*x[2]^2-5*x[1]*x[2]-15
- + f[2] <- 2*x[1]^4+5*x[2]^4+x[1]^3*x[2]-6*x[1]*x[2]^3-36
- + f
- + }
- >
- > p0 <- c(0.5, 1.5)
- > BBsolve(par=p0, fn=func)
- Successful convergence.
- $par
- [1] 1 2
- $residual
- [1] 9.228859e-08
- $fn.reduction
- [1] 0.00259409
- $feval
- [1] 88
- $iter
- [1] 14
- $convergence
- [1] 0
- $message
- [1] "Successful convergence"
- $cpar
- method M NM
- 2 50 1
复制代码