erfc(x)函数详解

首页 / C++入门教程 / erfc(x)函数详解

erfc()函数计算传递给该函数的参数的互补误差函数值。

假设数字为'x':

erfc(x) = 1-erf(x);

erfc - 语法

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

erfc - 参数

x :这是一个浮点值。

erfc - 返回值

它返回x的互补误差函数值。

参数 返回值
x=+∞ +0
x= -∞ 2
x=nan nan

erfc - 例子1

让我们看一个简单的例子,当x的值为+∞时。

链接:https://www.learnfk.comhttps://www.learnfk.com/c++/cpp-math-erfc-function.html

来源:LearnFk无涯教程网

#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值。

erfc - 例子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。

无涯教程网

erfc - 例子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。

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

Go语言核心36讲 -〔郝林〕

许式伟的架构课 -〔许式伟〕

设计模式之美 -〔王争〕

RPC实战与核心原理 -〔何小锋〕

图解 Google V8 -〔李兵〕

Flink核心技术与实战 -〔张利兵〕

性能优化高手课 -〔尉刚强〕

Spring Cloud 微服务项目实战 -〔姚秋辰(姚半仙)〕

云时代的JVM原理与实战 -〔康杨〕

好记忆不如烂笔头。留下您的足迹吧 :)