# 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 point of the interval
upper: upper end point of the interval

Example 1:

 `# R program to calculate root of an equation ` ` `  `# Function with equation ` `fun <``-` `function(x) {``2` `*` `x ^ ``2` `-` `4` `*` `x ``-``10``} ` ` `  `# Calling uniroot() function ` `uniroot(fun, lower ``=` `0``, upper ``=` `4``) `

Output:

```\$root
 3.449485

\$f.root
 -4.310493e-05

\$iter
 5

\$init.it
 NA

\$estim.prec
 6.103516e-05
```

Example 2:

 `# R program to calculate root of an equation ` ` `  `# Function with equation ` `fun <``-` `function(x) {``2` `*` `x ^ ``2` `-` `4` `*` `x ``-``10``} ` ` `  `# Calling uniroot() function ` `uniroot(fun, c(``0``, ``4``))\$root ` `uniroot(fun, lower ``=` `-``4``, upper ``=` `0``)\$root `

Output:

``` 3.449485
 -1.44949
```
My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.