Lab 2 - MATHEMATICAL FUNCTIONS IN R
Lab 2 - MATHEMATICAL FUNCTIONS IN R
MATHEMATICAL FUNCTIONS IN R –
INTEGRATION
AIM :
To integrate the polynomial function f ( x )=x 3 +2 x 2+ x +1 over the interval [0, 2].
PROCEDURE:
1. Open R-Studio.
4. Use the `integrate` function to find the definite integral of the function over the
specified interval.
R Code :
$ value
[1] 12
$ abs.error
[1] 1.332268e-13
Conclusion:
Viva Questions:
5. What does the `abs.error` field represent in the output of the `integrate` function?
2. Integration of a Trigonometric Function
AIM:
To integrate the trigonometric function f(x) = sin(x) over the interval [0, π].
PROCEDURE:
1. Open RStudio.
4. Use the `integrate` function to find the definite integral of the function over the
specified interval.
R Code :
Output :
$ value
[1] 2
$ abs.error
[1] 2.220446e-14
Conclusion:
The definite integral of the trigonometric function f ( x )=sin ( x ) over the interval [0, π]
is 2.
Viva Questions:
Aim :
To integrate the exponential function f(x) = e^x over the interval [0, 1].
PROCEDURE:
1. Open RStudio.
4. Use the `integrate` function to find the definite integral of the function over the
specified interval.
R Code :
Output:
$ value
[1] 1.718282
$ abs.error
[1] 1.907346e-14
Conclusion:
The definite integral of the exponential function f(x) = e^x over the interval [0, 1] is
approximately 1.718.
Viva Questions:
5. How does R's ‘ integrate` function handles the precision of exponential functions?
4. Integration of a Logarithmic Function
AIM :
To integrate the logarithmic function f(x) = log(x) over the interval [1, 2].
PROCEDURE:
1. Open RStudio.
4. Use the `integrate` function to find the definite integral of the function over the
specified interval.
R Code :
Output :
$ value
[1] 0.3862944
$ abs.error
[1] 4.289582e-15
Conclusion:
The definite integral of the logarithmic function f(x) = log(x) over the interval
Viva Questions:
3. What are the properties of logarithmic functions that affect their integration?
AIM:
To integrate the rational function f(x) = 1/(x^2 + 1) over the interval [0, 1].
Procedure:
1. Open RStudio.
4. Use the `integrate` function to find the definite integral of the function over the
specified interval.
R Code :
print(result)
Output:
$ value
[1] 0.7853982
$ abs.error
[1] 8.719671e-15
Conclusion:
1
The definite integral of the rational function f ( x )= 2
, over the interval [0, 1] is
(x +1)
approximately 0.785.
Viva Questions: