Description Details Author(s) References See Also Examples
Roots of functions of one variable.
At 2011-8-18, this package is for finding one real root of a supplied function of a single variable within a specified interval, or to report that the function has the same sign at each end of the interval.
John C. Nash <nashjc@uottawa.ca>
References to Brent and Dekker need to be added.
Brent
Dekker
Nash J C (1979) Compact numerical methods for computers, Adam-Hilger: Bristol. Second Edition, 1990, Institute of Physics Publications: Bristol.
optimize
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | cat("simple polynomial test\n")
tf1<-function(x) { 10 - 3*x + x*x*x }
gtf1<-function(x) { -3 + 3*x*x }
tint<-c(-4,4)
# curve(tf1, tint) ## uncomment to draw
res1<-root1d(tf1, tint)
cat("res1\n")
print(unlist(res1))
res2<-zeroin(tf1,tint)
cat("res2\n")
print(unlist(res2))
x0<-tint[1]
res3a<-newt1d(tf1, gtf1, x0)
print(unlist(res3a))
x0<-tint[2]
res3b<-newt1d(tf1, gtf1, x0)
print(unlist(res3b))
## cat("exponential example\n")
## efn<-function(x) { exp(-alpha*x) - 0.02 }
## gefn<-function(x){-alpha*exp(-alpha*x) }
## mymeth <- c("zeroin", "root1d", "newt1d")
## cat("seems to break here\n")
## for (al in 1:10){
## alpha<- 0.05*al
## tint <- c(0, 10/alpha)
## res<-multrfind(fn=efn, gr=gefn, ri=tint, ftrace=TRUE, meths=mymeth, alpha=alpha)
## cat("alpha=",alpha,":\n")
## res
## }
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.