On 11-12-2013, at 23:56, eliza botto <eliza_bo...@hotmail.com> wrote:
> Dear Berend, > > Thankyou very much indeed for you reply. By taking help from your previous > reply @ http://r.789695.n4.nabble.com/Simultaneous-equations-td2524645.html i > was able to generate the following loop for the calculation of x=x[1] and > y=x[2]. > > > fun <- function(x) { > > f <- numeric(length(x)) > # read as: > > > f[1] <- > 1-0.514-(gamma(1/x[1])*gamma(2/x[1]-1/x[2]))/(gamma(2/x[1])*gamma(1/x[1]-1/x[2])) > > f[2] <- 0.57- > > (gamma(1/x[1]-1/x[2])/gamma(1/x[1])-3*gamma(2/x[1]-1/x[2])/gamma(2/x[1])+2*gamma(3/x[1]-1/x[2])/gamma(3/x[1]))/(gamma(1/x[1]-1/x[2])/gamma(1 > > /x[1])-gamma(2/x[1]-1/x[2])/gamma(2/x[1])) > > f > > } > > > startx <- c(0.1,0.15) # start the answer search here > > answers<-as.data.frame(nleqslv(startx,fun)) > > answers > > What i cant understand is the concept involved for setting "startx". my x[1] > should always be smaller than x[2] and they both should be less than 1. how > can i demonstrate it to startx command line? > I don’t quite understand what you you mean. Your starting values obey the restrictions you specify (if that is what you meant). The solution vector has all elements > 1. But it is a solution. Do you mean that you want a solution satisfying the constraints you mention? I cannot tell if that is possible. Generally speaking a square system of equations is solved or not. Sometimes you can vary the starting values to get a different solution that obeys the specified constraints. If these constraints are necessary you are not solving a system of equations but trying to find a parameter set that satisfies certain criteria. Together with a criterion (sum of squares of function values for example) you could use an optimizing algorithm (optim, nlmin, constrOptim to name a few). Berend > thanks for your help. I m grateful. > > Eliza > > > > > > Subject: Re: [R] solving simultaneous Equations in R > > From: b...@xs4all.nl > > Date: Wed, 11 Dec 2013 12:43:02 +0100 > > CC: r-help@r-project.org > > To: eliza_bo...@hotmail.com > > > > > > On 11-12-2013, at 12:16, eliza botto <eliza_bo...@hotmail.com> wrote: > > > > > Dear users of R, > > > I'm trying to solve the following 2 equations simultaneously in R for "x" > > > and "y". I couldn't get through due to my limited knowledge of R. > > > > > > 3=1-[(x-1)!(2x-y-1)!/(2x-1)!(x-y-1)!] > > > > > > 6={[(x-y-1)!/(x-1)!]-[3(2x-y-1)!/(2x-1)!]+[2(3x-y-1)!/(3x-1)!]}/{[(x-y-1)!/(x-1)!]-[(2x-y-1)!/(2x-1)!]} > > > > > > obviously, ! is factorial. > > > kindly help me out on it or at least suggest something. > > > I'll be extremely grateful. > > > > There are several packages that solve a system of equations. > > ktsolve, nleqslv, BB, which you can find in CRAN Task views: "Numerical > > Mathematics” and “Optimization”. > > > > You will have to write your equations in standard R notation. > > I can’t tell if your system is solvable. > > > > Berend > > > > > Eliza > > > > > > > > > > > > [[alternative HTML version deleted]] > > > > > > ______________________________________________ > > > R-help@r-project.org 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@r-project.org 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.