The log1p() function takes an argument x and returns the natural logarithm of the base-e logarithm of x+1. Here e is a mathematical constant with value equal to 2.71828.
double log1p (double x); float log1p (float x); long double log1p (long double x);
- The log1p() function takes a single argument in the range [-1, ?].
- If we pass the value which is less than -1, log1p() returns Nan (Not a Number).
- a positive number : if x > 0
- zero if x=0
- a negative number if -1 > x > 0
- -?(- infinity) if x=-1
- NaN if x<-1
Error and Exception:
- It is mandatory to give both the arguments otherwise it will give error no matching function for call to ‘log1p()’.
- If we pass the string as argument we will get errorbno matching function for call to ‘log1p(const char [n]).
- It gives -inf if we pass -1.
- It gives zero if we pass 0.
Input : log1p(50.35) Output : 3.93866
Input : log1p(143) Output : 4.96981
# CODE 1
log1p(50.35) = 3.93866
# CODE 2
log1p(143) = 4.96981
- It is practically used to get logarithm value of given argument+1.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Learn C++ Programming Step by Step - A 20 Day Curriculum!
- Why do we need reference variables if we have pointers
- Similarities and Difference between Java and C++
- Macros and its types in C/C++
- How to find index of a given element in a Vector in C++
- Introduction to Complex Objects and Composition
- NULL undeclared error in C/C++ and how to resolve it
- std::remove_const in C++ with Examples
- Finding Median of unsorted Array in linear time using C++ STL
- Average of Cubes of first N natural numbers
- Top 10 Programming Languages for Blockchain Development
- Memory Allocation in Static Data Members in C++
- Exception header in C++ with examples
- Mutual friendship of Classes in C++ with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.