Home » Java programming language

Java StrictMath expm1() Method with Example

StrictMath Class expm1() method: Here, we are going to learn about the expm1() method of StrictMath Class with its syntax and example.
Submitted by Preeti Jain, on January 05, 2020

StrictMath Class expm1() method

  • expm1() Method is available in java.lang package.
  • expm1() Method is used to return [ the exponential of the given number – 1] in the method or in other words it is used to calculate the ( e raised to the power of the given argument – 1). Here, "expm" stands for exponentiation.
  • expm1() Method is a static method so it is accessible with the class name and if we try to access the method with the class object then we will not get any error.
  • expm1() Method does not throw any exception.

Syntax:

    public static double expm1(double d);

Parameter(s):

  • double d – represents the exponent to raise the power of e-1.

Return value:

The return type of the method is double, it returns (The exponentiation of the given argument -1).

Note:

  • If we pass NaN, the method returns the NaN.
  • If we pass positive infinity, the method returns the same (positive infinity).
  • If we pass negative infinity, the method returns -1.0.
  • If we pass zero, the method returns the same value with the same sign.

Example:

// Java program to demonstrate the example
// of expm1(double d) method of StrictMath Class.

public class Expm1 {
    public static void main(String[] args) {
        // variable declarations
        double d1 = 7.0 / 0.0;
        double d2 = -7.0 / 0.0;
        double d3 = 0.0;
        double d4 = -0.0;
        double d5 = 0.8;
        double d6 = 2;


        // Display previous value of d1,d2,d3, d4,d5 and d6 
        System.out.println(" d1: " + d1);
        System.out.println(" d2: " + d2);
        System.out.println(" d3: " + d3);
        System.out.println(" d4: " + d4);
        System.out.println(" d5: " + d5);
        System.out.println(" d6: " + d6);


        // Here , we will get (Infinity) because we are 
        // passing parameter whose value is (infinity)
        System.out.println("StrictMath.expm1(d1): " + StrictMath.expm1(d1));

        // Here , we will get (-1.0) because we are 
        // passing parameter whose value is (-infinity)
        System.out.println("StrictMath.expm1(d2): " + StrictMath.expm1(d2));

        // Here , we will get (0.0) because we are 
        // passing parameter whose value is (0.0)
        System.out.println("StrictMath.expm1(d3): " + StrictMath.expm1(d3));

        // Here , we will get (-0.0) because we are 
        // passing parameter whose value is (-0.0)
        System.out.println("StrictMath.expm1(d4): " + StrictMath.expm1(d4));

        // Here , we will get [(e raised to the power of 0.8) - 1] because we are 
        // passing parameter whose value is (0.8)
        System.out.println("StrictMath.expm1(d5): " + StrictMath.expm1(d5));

        // Here , we will get [(e raised to the power of 2) - 1] because we are
        // passing parameter whose value is (2)
        System.out.println("StrictMath.expm1(d6): " + StrictMath.expm1(d6));
    }
}

Output

 d1: Infinity
 d2: -Infinity
 d3: 0.0
 d4: -0.0
 d5: 0.8
 d6: 2.0
StrictMath.expm1(d1): Infinity
StrictMath.expm1(d2): -1.0
StrictMath.expm1(d3): 0.0
StrictMath.expm1(d4): -0.0
StrictMath.expm1(d5): 1.2255409284924677
StrictMath.expm1(d6): 6.38905609893065





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.