Open In App

Compute the Second Derivative of the Logarithmic value of the gamma Function in R Programming - trigamma() Function

Last Updated : 12 Jun, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
trigamma() function in R Language is used to calculate the second derivative of the natural logarithm of the gamma value calculated using the gamma function. trigamma Function is basically,
trigamma(x) = d2(ln(factorial(n-1)))/dx2
Syntax: trigamma(x) Parameters: x: Numeric vector
Example 1: Python3 1==
# R program to find second derivative 
# of the lgamma value

# Calling the trigamma() Function
trigamma(2)
trigamma(4)
trigamma(5.2)
Output:
[1] 0.6449341
[1] 0.283823
[1] 0.2119756
Example 2: Python3 1==
# R program to find second derivative 
# of the lgamma value

# Creating a vector
x <- c(2.3, 3, 1.2)

# Calling the trigamma() Function
trigamma(x)

# Calling trigamma() function
# on negative values
trigamma(-2.3)
trigamma(-2)
Output:
[1] 0.5425375 0.3949341 1.2673772
[1] 14.72591
[1] Inf

Next Article
Article Tags :

Similar Reads