[R] Solve equations

Gabor Grothendieck ggrothendieck at gmail.com
Mon Aug 6 16:23:43 CEST 2007

```Try brute force:

> f <- function(x) {
+ V <- x[1]; W <- x[2]; X <- x[3]; Y <- x[4]; Z <- x[5]
+ if (!(V < W && W < X && Y < Z)) return(Inf)
+ ((0.007 - 2*V*Z)^2 +
+ (0.03 - W*(Y+Z))^2 +
+ (0.034 - X*(Y+Z))^2 +
+ (X - W+V)^2 +
+ (0.013 - (X+W)*Y +(X-W)*Z))^2
+ }
> s <- 1:10/10
> g <- expand.grid(V = s, W = s, X = s, Y = s, Z = s)
> idx <- which.min(apply(g, 1, f))
> idx
[1] 10541
> g[idx,]
V   W   X   Y   Z
10541 0.1 0.5 0.6 0.1 0.2
> as.vector(f(g[idx,]))
[1] 3.8025e-08

On 8/6/07, sebastien puechmaille <sebastien.puechmaille at ucd.ie> wrote:
> Hello,
>
>  I have a system of five equations to solve with five 'unknows'(V, W, X,
> Y and Z) and  constraints. The equations are:
> 0.007= 2VZ
> 0.03= W(Y+Z)
> 0.034= X(y+Z)
> 0.013 = (X+W)Y +(X-W)Z
> X = W+V
> Constraints:
> 0<V<W<X
> 0<Y<Z<1
>
> Does anyone know a R-package to solve this system?
>
>  Thanks,
>
> E-mail: sebastien.puechmaille at ucd.ie
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help