Skip to content
Related Articles
Open in App
Not now

Related Articles

Compute Single Order Integral value of a Function in R Programming – integrate() Function

Improve Article
Save Article
Like Article
  • Last Updated : 30 Jun, 2020
Improve Article
Save Article
Like Article

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, use below command:

help("integrate")

Example 1:




# Create function
f<-function(x) x^3 + 2*x
  
# Integrate from 0 to 1
integrate(f, 0, 1)


Output:

1.25 with absolute error < 1.4e-14

Example 2:




# Create function
f <- function(x) {1/((x+1)*sqrt(x))}
  
# Integrate from 0 to 5
integrate(f, lower = 0, upper = 5)


Output:

2.300524 with absolute error < 0.00011
My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!