optimize() or optimise() function in R Language is used to search the interval from lower to upper for a minimum or maximum of the function f with respect to its first argument.
Syntax: optimize(f, interval, maximum)
f: the function to be optimized. The function is either minimized or maximized over its first argument depending on the value of maximum.
interval: a vector containing the end-points of the interval to be searched for the minimum.
maximum: the logical value says to maximize or minimize. Its default value is minimize.
$minimum  1.2 $objective  9.8
$maximum  -4.999944 $objective  201.9965
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.