exp() function C++ Last Updated : 08 Feb, 2023 Comments Improve Suggest changes Like Article Like Report The exp() function in C++ returns the exponential (Euler's number) e (or 2.71828) raised to the given argument. Syntax for returning exponential e: result=exp() Parameter: The function can take any value i.e, positive, negative or zero in its parameter and returns result in int, double or float or long double. Return Value: The exp() function returns the value in the range of [0, inf]. Error: It shows error when we pass more than one argument in exp function When the input value is too large, the exp function can return inf or nan as a result, indicating overflow. Application: Given below is an example of application of exp() function CPP #include <bits/stdc++.h> using namespace std; // function to explain use of exp() function double application(double x) { double result = exp(x); cout << "exp(x) = " << result << endl; return result; } // driver program int main() { double x = 10; cout << application(x); return 0; } Outputexp(x) = 22026.5 22026.5 Time Complexity: O(1)Auxiliary Space: O(1) Here is the program to demonstrate the error in exp() function. C++ #include <bits/stdc++.h> using namespace std; // function to explain use of exp() function double application(double x) { double result = exp(x); cout << "exp(x) = " << result << endl; return result; } // driver program int main() { double x = 1000; cout << application(x); return 0; } Outputexp(x) = inf inf Time Complexity: O(1)Auxiliary Space: O(1) Applications of e (mathematical constant): Compound Interest : An account that starts at $1 and offers an annual interest rate of R will, after t years, yield eRt dollars with continuous compounding (Here R is the decimal equivalent of the rate of interest expressed as a percentage, so for 5% interest, R = 5/100 = 0.05)Value of below expression is e. \lim _{n\to \infty }\left(1+{\frac {1}{n}}\right)^{n}.The probability that a gambler never wins if he/she tries million times in a game where chances of winning in every trial is one by million is close to 1/e.The number e is the sum of the infinite series e=\sum _{n=0}^{\infty }{\frac {1}{n!}}={\frac {1}{0!}}+{\frac {1}{1!}}+{\frac {1}{2!}}+{\frac {1}{3!}}+{\frac {1}{4!}}+\cdots \,, Source : Wiki Comment More infoAdvertise with us Next Article exp() function C++ S Striver Follow Improve Article Tags : Misc C++ CPP-Library Practice Tags : CPPMisc Similar Reads exp2() function in C++ STL The exp2() is a builtin function in C++ STL that computes the base-2 exponential function of a given number. It can also be written as 2num. Syntax: exp2(data_type num) Parameter: The function accepts a single mandatory parameter num which specifies the value of the exponent. It can be positive, neg 2 min read Functions in C++ A function is a building block of C++ programs that contains a set of statements which are executed when the functions is called. It can take some input data, performs the given task, and return some result. A function can be called from anywhere in the program and any number of times increasing the 9 min read valarray exp() function in C++ The exp() function is defined in valarray header file. This function is used to calculate e raised to the power equal to the value of the element in valarray. Syntax: exp(varr); Parameter: This function takes a mandatory parameter varr which represents valarray. Returns: This function returns a vala 2 min read expm1() in C++ The expm1(x) function returns ex - 1 where x is an argument and e is mathematical constant with value equal to 2.71828. Syntax: double expm1() (double x); float expm1() (float x); long double expm1() (long double x);The expm1() function takes a single argument and computes e^x -1.The expm1() functio 2 min read frexp() in C++ The frexp() function breaks the floating point number x into its binary significand i., e., floating point with an absolute value between [0.5, 1.0) and an integral exponent for 2. x = significand * (2^exponent). It used to : 1. It is used to find significand which is always between 0.5 and 1.0 2. I 2 min read std::function in C++ The std::function() in C++ is a function wrapper class which can store and call any function or a callable object. In this article, we will learn about std::function in C++ and how to use it in different cases.Table of ContentWhat is std::function in C++?Example of std::functionMember Functions of s 5 min read log() Function in C++ The std::log() in C++ is a built-in function that is used to calculate the natural logarithm (base e) of a given number. The number can be of any data type i.e. int, double, float, long long. It is defined inside the <cmath> header file.In this article we will learn about how to use std::log() 1 min read ldexp() function in C/C++ The ldexp() is a built-in function in C/C++ gives the product of any variable x and 2 raised to the power of exp by taking two arguments x and exp i.e., x * 2^exp Syntax: float ldexp (float x, int exp) double ldexp (double x, int exp) long double ldexp (long double x, int exp) double ldexp (T x, int 2 min read C++ Map of Functions Prerequisites: Functions in C++Map in C++ Maps in C++ are a very useful data structure for storing key-value pairs. A map is the best way to store where we can directly find and access the value using a key with the best time complexity. However, did you know that you can also store functions as val 5 min read fegetexceptflag() function in C/C++ The fegetexceptflag() function in C/C++ is specified in header file fenv.h and gets floating point exception flags. This function store the raised exception in the point specified by flagp . Syntax: int fegetexceptflag(fexcept_t* flagp, int excepts) Parameters: The function accepts two mandatory par 2 min read Like