# Optimization problem

6 messages
Open this post in threaded view
|

## Optimization problem

 As a simple example, I want to find minimum value for x^2, but it can't be obtained by: f<-function(x)x^2 optimize(f,lower=-1,upper=1) What are other methods to deal with this? I tried DEoptim, still doesn't work. Any suggustions will be extremely helpful! THanks! Shelly
Open this post in threaded view
|

## Re: Optimization problem

 On Apr 10, 2013, at 03:24 , nntx wrote: > As a simple example, I want to find minimum value for x^2, but it can't be > obtained by: > f<-function(x)x^2 > optimize(f,lower=-1,upper=1) Works fine for me. What did you expect it to do? > f<-function(x)x^2 > optimize(f,lower=-1,upper=1) \$minimum [1] -2.775558e-17 \$objective [1] 7.70372e-34 -pd > > What are other methods to deal with this? I tried DEoptim, still doesn't > work. Any suggustions will be extremely helpful! THanks! > > > Shelly > > > > -- > View this message in context: http://r.789695.n4.nabble.com/Optimization-problem-tp4663821.html> Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > [hidden email] 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. -- Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: [hidden email]  Priv: [hidden email] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Optimization problem

 Thank you professor. I think the minimum value of x^2 between -1 and 1 should be x=0, y=0. but the result is not that. I am thinking is any wrong with my thought? Thanks for helping me out!
Open this post in threaded view
|

## Re: Optimization problem

 Hello, Your thoght is mathematically right but numerically wrong. The result given by optimize is so close to the real minimum that numerical accuracy comes in and it becomes indistinguishable from the value you're expecting. You get the minimum up to a certain accuracy, not more. Hope this helps, Rui Barradas Em 10-04-2013 19:33, nntx escreveu: > Thank you professor. I think the minimum value of x^2 between -1 and 1 should > be x=0, y=0. but the result is not that. I am thinking is any wrong with my > thought? > Thanks for helping me out! > > > > -- > View this message in context: http://r.789695.n4.nabble.com/Optimization-problem-tp4663821p4663898.html> Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > [hidden email] 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. > ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.