{"id":24244,"date":"2021-10-14T09:19:06","date_gmt":"2021-10-14T03:49:06","guid":{"rendered":"https:\/\/python-programs.com\/?p=24244"},"modified":"2021-11-05T21:02:12","modified_gmt":"2021-11-05T15:32:12","slug":"python-program-for-expm1-function","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-expm1-function\/","title":{"rendered":"Python Program for expm1() Function"},"content":{"rendered":"
In the previous article, we have discussed Python Program for exp() Function<\/a> Ex<\/sup>\u00a0– 1 is returned by the math.expm1() method.<\/p>\n ‘E’ is the natural logarithmic system’s base (approximately 2.718282), and x is the number passed to it.<\/p>\n This function is more precise than using math. exp() and subtracting 1.<\/p>\n Syntax:<\/strong><\/p>\n Parameters:<\/strong><\/p>\n x: <\/strong>This is required. It is a number. The exponent is specified.<\/p>\n Return Value:<\/strong><\/p>\n It returns a value float value which represents \u00a0Ex<\/sup> – 1.<\/p>\n Examples:<\/strong><\/p>\n Example1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Know all about Mathematical Functions in Python by going through our Python Mathematical Methods Examples<\/a> well explained step by step.<\/p>\n In the previous article, we have discussed Python Program for exp() Function expm1() Function in Python: Ex\u00a0– 1 is returned by the math.expm1() method. ‘E’ is the natural logarithmic system’s base (approximately 2.718282), and x is the number passed to it. This function is more precise than using math. exp() and subtracting 1. Syntax: math.expm1(x) …<\/p>\n
\nexpm1() Function in Python:<\/strong><\/p>\nmath.expm1(x)<\/pre>\n
Given Number = 3<\/pre>\n
The result after applying expm1() function on above given number 3 = 19.085536923187668<\/pre>\n
Given Number = 5.5<\/pre>\n
The result after applying expm1() function on above given number 5.5 = 243.69193226422038<\/pre>\n
Program for expm1() Function in Python<\/h2>\n
\n
Method #1: Using Built-in Functions (Static Input)<\/h3>\n
\n
# Import math module using the import keyword.\r\nimport math\r\n# Give the list as static input and store it in a variable.\r\ngvn_lst = [9, 4, 5, 2, 1]\r\n# Give the first number as static input and store it in another variable.\r\ngvn_numb1 = 3\r\n# Apply math.expm1() function to the given first number to calculate the value\r\n# E raised to the power of given number-1.(E =approximately 2.718282)\r\n# Store it in another variable.\r\nfnl_rslt = math.expm1(gvn_numb1)\r\nprint(\"The result after applying expm1() function on above given first number\",\r\n gvn_numb1, \" = \", fnl_rslt)\r\n# similarly do the same for the other number.\r\ngvn_numb2 = 5.5\r\nprint(\"The result after applying expm1() function on above given second number\",\r\n gvn_numb2, \" = \", math.expm1(gvn_numb2))\r\n# Apply math.expm1() function to the given list element and print it.\r\nprint(\r\n \"The result after applying expm1() function on given list element gvnlst[1] = \", math.expm1(gvn_lst[1]))\r\n<\/pre>\n
The result after applying expm1() function on above given first number 3 = 19.085536923187668\r\nThe result after applying expm1() function on above given second number 5.5 = 243.69193226422038\r\nThe result after applying expm1() function on given list element gvnlst[1] = 53.598150033144236<\/pre>\n
Method #2: Using Built-in Functions (User Input)<\/h3>\n
\n
# Import math module using the import keyword.\r\nimport math\r\n# Give the list as user input using list(),map(),input(),and split() functions.\r\n# Store it in a variable.\r\ngvn_lst = list(map(float, input(\r\n 'Enter some random List Elements separated by spaces = ').split()))\r\n# Give the first number as user input using the float(input()) function\r\n# and store it in a variable.\r\ngvn_numb1 = float(input(\"Enter some random number = \"))\r\n# Apply math.expm1() function to the given first number to calculate the value\r\n# E raised to the power of given number-1.(E =approximately 2.718282)\r\n# Store it in another variable.\r\nfnl_rslt = math.expm1(gvn_numb1)\r\nprint(\"The result after applying expm1() function on above given first number\",\r\n gvn_numb1, \" = \", fnl_rslt)\r\n# similarly do the same for the other number.\r\ngvn_numb2 = float(input(\"Enter some random number = \"))\r\nprint(\"The result after applying expm1() function on above given second number\",\r\n gvn_numb2, \" = \", math.expm1(gvn_numb2))\r\n# Apply math.expm1() function to the given list element and print it.\r\nprint(\r\n \"The result after applying expm1() function on given list element gvnlst[2] = \", math.expm1(gvn_lst[2]))\r\n<\/pre>\n
Enter some random List Elements separated by spaces = 46 2 1 80 2\r\nEnter some random number = 4\r\nThe result after applying expm1() function on above given first number 4.0 = 53.598150033144236\r\nEnter some random number = 3.5\r\nThe result after applying expm1() function on above given second number 3.5 = 32.11545195869231\r\nThe result after applying expm1() function on given list element gvnlst[2] = 1.718281828459045<\/pre>\n
\n