On Thu, Jul 26, 2012 at 5:16 PM, Diviya Smith <diviya.sm...@gmail.com>wrote:
> Thank you for pointing me to the uniroot function? > > Is there a way to constrain this solution so that it only gives me values > of 'a' between c(0,1)? > > I tried using nlminb and for some reason it always estimates a = 0, even > when I change the objective function. > > f <- function(vals) { > > x <- vals[1] > > sum(c(x^2-x-8.013)^2) > > } > > nlminb(c(0.05),f, lower=0.00, upper=1.00) > > > > On Thu, Jul 26, 2012 at 5:00 PM, è¾è´¨æ <ggg...@gmail.com> wrote: > >> I think it's impossible for 'a' between c(0,1) to satisfy that >> >> a^2 - a = 8.313 >> Without the restraint, you can try following lines to get roots: >> >> >> fun=function(a) a^2-a-8.313 >> >> root1=uniroot(fun,c(3,4)) >> >> root2=uniroot(fun,c(-3,-2)) >> >> Eric >> >> On Thu, Jul 26, 2012 at 4:49 PM, Diviya Smith <diviya.sm...@gmail.com>wrote: >> >>> Sorry it is important for me to constrain the value of 'a' between c(0,1) >>> >>> On Thu, Jul 26, 2012 at 4:48 PM, Diviya Smith <diviya.sm...@gmail.com >>> >wrote: >>> >>> > Hi there, >>> > >>> > I would like to solve a simple equation in R >>> > >>> > a^2 - a = 8.313 >>> > >>> > There is no real solution to this problem but I would like to get an >>> > approximate numerical solution. Can someone suggest how I can set this >>> up? >>> > >>> > Thanks in advance, >>> > Diviya >>> > >>> >>> [[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. >>> >> >> > [[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.