Search the Interval for Minimum and Maximum of the Function in R Programming - optimize() Function Last Updated : 15 Jul, 2025 Comments Improve Suggest changes Like Article Like Report 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)Parameters: 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. Example 1: Python3 # R program to illustrate # optimize function # Specifying a function f <- function(x) {5 * x ^ 2 - 12 * x + 17} # Calling the optimize() function # over the interval of -5 to 5, to # minimize the value optimize(f, interval = c(-5, 5)) Output: $minimum [1] 1.2 $objective [1] 9.8 Example 2: Python3 # R program to illustrate # optimize function # Specifying a function f <- function(x) {5 * x ^ 2 - 12 * x + 17} # Calling the optimize() function # over the interval of -5 to 5, to # maximize the value optimize(f, interval = c(-5, 5), maximum = T) Output: $maximum [1] -4.999944 $objective [1] 201.9965 Comment More infoAdvertise with us Next Article Return the Index of the First Minimum Value of a Numeric Vector in R Programming - which.min() Function K Kanchan_Ray Follow Improve Article Tags : R Language R Object-Function Similar Reads Get the Minimum and Maximum element of a Vector in R Programming - range() Function range() function in R Programming Language is used to get the minimum and maximum values of the vector passed to it as an argument. Syntax: range(x, na.rm, finite) Parameters:Â x: Numeric Vectorna.rm: Boolean value to remove NAfinite: Boolean value to exclude non-finite elementsR - range() Function 1 min read Compute Single Order Integral value of a Function in R Programming - integrate() Function integrate() function in R Language is used to compute single order integral of the function provided. Syntax: integrate(f, lower, upper) Parameters: f: represents a function lower: represents lower limit of integration upper: represents upper limit of integration To know about more option parameters 1 min read Return the Index of the First Maximum Value of a Numeric Vector in R Programming - which.max() Function which.max() function in R Language is used to return the location of the first maximum value in the Numeric Vector. Syntax: which.max(x) Parameters: x: Numeric Vector Example 1: Python3 1== # R program to find index of # first maximum value # Creating a vector x <- c(2, 3, 4, 5, 1, 2, 3, 1, 2) # 1 min read Get the Minimum element of an Object in R Programming - min() Function min() function in R Language is used to find the minimum element present in an object. This object can be a Vector, a list, a matrix, a data frame, etc.. Syntax: min(object, na.rm) Parameters: object: Vector, matrix, list, data frame, etc. na.rm: Boolean value to remove NA element. Example 1: Python 1 min read Return the Index of the First Minimum Value of a Numeric Vector in R Programming - which.min() Function which.min() function in R Language is used to return the location of the first minimum value in the Numeric Vector. Syntax: which.min(x) Parameters: x: Numeric Vector Example 1: Python3 1== # R program to find index of # first minimum value # Creating a vector x <- c(2, 3, 4, 5, 1, 2, 3, 1, 2) # 1 min read Calculate the Root of a Equation within an interval in R Programming - uniroot() Function uniroot() function in R Language is used to calculate the root of an equation with the lower and upper range of the interval passed as arguments. Syntax: uniroot(fun, interval, lower, upper) Parameters: fun: function with the equation interval: with upper and lower range of root lower: lower end poi 1 min read Like