Python math library – expm1() method:

The Python consists of a math library, and it has many functions. Such similar function is expm1(). The function mathematically computes value of exp() – 1b. This method is used in case of computing this value.

Code 1: Demonstrating the working of expm1()

Comparison between exp() -1 and expm1():

We use expm1() instead of exp() – 1 for smaller values of x of the order less than e-10, as it gives more accurate results.

Code 2: Comparison of expm1() and exp() – 1

 

Leave a Reply

Your email address will not be published. Required fields are marked *