Skip to content
Related Articles

Related Articles

Improve Article
Compute Single Order Integral value of a Function in R Programming – integrate() Function
  • Last Updated : 30 Jun, 2020

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
Recommended Articles
Page :