How to find the exponential value of a number using Math.exp() method in Java

2 Answers

0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

         System.out.println(Math.exp(2)); // e = 2.7182818 (^ 2)
         System.out.println(Math.exp(4)); // e = 2.7182818 (^ 4)
    }
}
   
/*
      
run:

7.38905609893065
54.598150033144236
  
*/

 



answered Nov 8, 2016 by avibootz
0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

        double a = 5;
        double b = 0.5;

        System.out.println("Math.exp(" + a + ") = " + Math.exp(a));
        System.out.println("Math.exp(" + b + ") = " + Math.exp(b));
    }
}
   
/*
      
run:

Math.exp(5.0) = 148.4131591025766
Math.exp(0.5) = 1.6487212707001282
  
*/

 



answered Nov 8, 2016 by avibootz
...