C++教程
C++控制语句
C++函数
C++数组
C++指针
C++对象
C++继承
C++多态
C++抽象
C++常用
C++ STL教程
C++迭代器
C++程序

C++ Math erfc()

C++ Math erfc()

erfc()函数计算传递给该函数的参数的互补误差函数值。
假设一个数字是" x" :
erfc(x) = 1-erf(x);

语法

float erfc(float x) ;
double erfc(double x) ;
long double erfc(long double x) ;
double erfc(integral x);

参数

x : 它是浮点值。

返回值

它返回x的互补误差函数值。
参数 返回值
x = +∞ +0
x =-∞ 2
x = nan nan

示例1

让我们看一下x值为+∞时的简单示例。
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
     float x= 2.0/0.0;
     cout<<"Value of x is : "<<x<<'\n';
     cout<<"erfc(x) : "<<erfc(x);
     return 0;
}
输出:
Value of x is : inf
erfc(x) : 0
在上面的示例中,x的值为正无限大。因此,函数erfc()返回0值。

示例2

让我们看一下x值为-∞时的简单示例。
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
     float x=-1.0/0.0;
     cout<<"Value of x is : "<<x<<'\n';
     cout<<"erfc(x) : "<<erfc(x);
     return 0;
}
输出:
Value of x is :-inf
erfc(x) : 2
在上面的示例中,x的值为负无穷大。因此,函数erfc()返回2、

示例3

让我们看一下x值为nan时的简单示例。
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
     float x= sqrt(-2);
     cout<<"Value of x is : "<<x<<'\n';
     cout<<"erfc(x) : "<<erfc(x);
     return 0;
}
输出:
Value of x is :-nan
erfc(x) :-nan
在上面的示例中,x的值为nan。因此,函数erfc()返回nan。

昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4