File: onepar_test.R

package info (click to toggle)
r-cran-optimx 2020-4.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,492 kB
  • sloc: sh: 21; makefile: 5
file content (15 lines) | stat: -rwxr-xr-x 495 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
library(optimx)
f1<-function(xx){ # function of one parameter
   ((3*xx+2)*xx-5)*xx+4
}
cat("The function does have a local minimum\n")
curve(f1, from=0, to=2)
X11()
cat("But it also can got to -infinity\n")
curve(f1, from=-50, to=50)
ansone<-optimx(c(1), f1, control=list(all.methods=TRUE))
print(ansone)
ansoneb<-optimx(c(1), f1, lower=c(-1), upper=c(10),control=list(all.methods=TRUE))
print(ansoneb)
ansoneb2<-optimx(1, f1, lower=-1, upper=10,control=list(all.methods=TRUE))
print(ansoneb2)