How to Apply the uniroot() Function in R (Example Code)

In this article you’ll learn how to apply the uniroot function in the R programming language.

Creation of Example Data

f <- function(x) {                           # Create user-defined function in R
  y <- 2 * x^3 - 10 * x^2 + 50 * x - 20000
}

Example: Get Root (Zero) of Function Using uniroot() Command

uniroot(f, interval = c(- 200, 200))$root    # Find one dimensional root
# [1] 22.92958

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top