Skip to content
Prev 301400 / 398503 Next

Solving quadratic equation in R

Hello,

Surely one of


f <- function(a) a^2 - a - 8.313

curve(f, from=0, to=1)
# zeros of f
root <- polyroot(c(-8.313, -1, 1))
ifelse(Im(root) == 0, Re(root), root)
# minimum of f
optimize(f, interval=c(0, 1))

Hope this helps,

Rui Barradas

Em 26-07-2012 22:13, Nordlund, Dan (DSHS/RDA) escreveu: