C++ Math tgamma()
 
 
 C++ Math tgamma()
 
  tgamma()函数计算传递给该函数的参数的gamma函数。
 
 假设数字 x: 
 
语法
 
 
 
  float tgamma(float x);
double tgamma(double x);
long double tgamma(long double x);
double tgamma(double x);
      
   
  
参数
 
  x : 它是浮点值。 
 
返回值
 
 它返回x的伽玛函数值。
 
 
 
   
   | 参数 | 返回值 | 
 
   
   | x =±0 | ±∞ | 
 
   
   | x =-ve | nan | 
 
   
   | x =-∞ | nan | 
 
   
   | x = +∞ | +∞ | 
 
   
   | x = nan | nan | 
 
 
 
示例1 
 
 让我们看一下x值为零时的简单示例。
 
 
 
  #include <iostream>
#include<math.h>
using namespace std;
int main()
{
     float x= 0.0;
     cout<<"Value of x is : "<<x<<'\n';
     cout<<"tgamma(x) : "<<tgamma(x);
     return 0;}
      
   
  
  输出: 
 
 
 
  Value of x is : 0
tgamma(x) : inf
      
   
  
 在上面的示例中,x的值为零。因此,函数tgamma()返回+∞。
 
示例2 
 
 让我们看看x的值为负时的简单示例。
 
 
 
  #include <iostream>
#include<math.h>
using namespace std;
int main()
{
     int x=-6;
     cout<<"Value of x is : "<<x<<'\n';
     cout<<"tgamma(x) : "<<tgamma(x);
     return 0;
}
      
   
  
  输出: 
 
 
 
  Value of x is :-6
tgamma(x) : nan
      
   
  
 在上面的示例中,x的值为负整数。因此,函数tgamma()返回nan。
 
示例3 
 
 让我们看一下x值为-∞时的简单示例。
 
 
 
  #include <iostream>
#include<math.h>
using namespace std;
int main()
{
     float x=-9.0/0.0;
     cout<<"Value of x is : "<<x<<'\n';
     cout<<"tgamma(x): "<<tgamma(x);
     return 0;
}
      
   
  
  输出: 
 
 
 
  Value of x is :-inf
tgamma(x): nan
      
   
  
 在上面的示例中,x-∞的值。因此,函数tgamma()返回nan。
 
示例4 
 
 让我们看一个简单的示例,当的值为+∞时。
 
 
 
  #include <iostream>
#include<math.h>
using namespace std;
int main()
{
     float x= 7.8/0.0;
     cout<<"Value of x is : "<<x<<'\n';
     cout<<"tgamma(x) : "<<tgamma(x);
     return 0;
}
      
   
  
  输出: 
 
 
 
  Value of x is : inf
tgamma(x) : inf
      
   
  
 在上面的示例中,x的值为+∞。因此,函数tgamma()返回+∞。 
 
示例5 
 
 让我们看一下x值为nan时的简单示例。
 
 
 
  #include <iostream>
#include<math.h>
using namespace std;
int main()
{
     float x= 0.0/0.0;
     cout<<"Value of x is : "<<x<<'\n';
     cout<<"tgamma(x) : "<<tgamma(x);
    return 0;
}
      
   
  
  输出: 
 
 
 
  Value of x is :-nan
tgamma(x) :-nan
      
   
  
 在上面的示例中,x的值为nan。因此,函数tgamma()返回nan。