How to Apply the optimize() Function in R (Example Code)
In this R tutorial you’ll learn how to apply the optimize function.
Example: Using optimize() to Perform One Dimensional Optimization in R
the_fun <- function(x) { # Creating own function 7 * x - 3 * x^2 + x^5 } |
the_fun <- function(x) { # Creating own function 7 * x - 3 * x^2 + x^5 }
optimize(the_fun, interval = c(- 5, 5)) # Applying optimize() function # $minimum # [1] -4.999944 # # $objective # [1] -3234.824 |
optimize(the_fun, interval = c(- 5, 5)) # Applying optimize() function # $minimum # [1] -4.999944 # # $objective # [1] -3234.824