Re: [R] Solve equations
Hi Sebastian, Your equations can be easily solved - no programming is required! Let's number you equations: (1) 0.007= 2VZ (2) 0.03= W(Y+Z) (3) 0.034= X(y+Z) (4) 0.013 = (X+W)Y +(X-W)Z (5) X = W+V Substitute (5) into (3) and then divide (2) by (3) to get (W+V)/W = 0.034/0.03 so that (6) V = (2/15)*W (7) X = V+W = (17/15)*W Substitute (7) into (3) and (4) to get: (3') (17/15)*(WY + WZ) = 0.034 (4') (32/15)WY + (2/15)WZ = 0.013 Solving (3') and (4') for two new unknowns WY and WZ yields (8) WY = 0.0045 (9) WZ = 0.0255 So that (10) Z = (17/3)*Y Substitute (10) into (1) to get 2*Y*(17/3)*Y = 0.07 So (since Y > 0), Y = sqrt(0.21/34) = 0.07859052 >From (10), Z = (17/3)*Y = 0.4453463 >From (8), W = 0.0045/Y = 0.05725881 >From (6), V = (2/15)*W = 0.007634508 Finally, X = V + W = 0.06489332 So there is a unique solution (which luckily satisfies your constraints!). Regards, Moshe. --- sebastien puechmaille <[EMAIL PROTECTED]> 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 0 > Does anyone know a R-package to solve this system? > > Thanks, > > E-mail: [EMAIL PROTECTED] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Solve equations
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 <[EMAIL PROTECTED]> 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 0 > Does anyone know a R-package to solve this system? > > Thanks, > > E-mail: [EMAIL PROTECTED] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Solve equations
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: 0https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] solve equations
It is probably very well explained in a basic math book which you either own or can borrow at many libraries. The method is called substitution and you most probably dont get much help or insight from R. If it is a linear equation system with more unknowns use the function 'solve' which you would have found by typing help.search("solve system") in R. Question to R help.search experts: Why doesn't help.search("solve Equations") find solve ? Cheers, Henrik wafa wrote: > Hi everyone, > > I need your help to use R to solve two equations with two unknown variables= > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] solve equations
Hi everyone, I need your help to use R to solve two equations with two unknown variables= __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html