Asked
Active
Viewed 62 times
-3
-
1See this [article](https://www.geeksforgeeks.org/program-to-efficiently-calculate-ex/). – Makdous May 05 '20 at 14:37
-
Does this answer your question? [Calculate e^x without inbuilt functions in Java](https://stackoverflow.com/questions/26140238/calculate-ex-without-inbuilt-functions-in-java) or [Recursively calculate e^x with Java](https://stackoverflow.com/questions/22065279/recursively-calculate-ex-with-java-using-maclaurin-series). – U880D May 05 '20 at 15:02
-
@U880D didn't answer my question – berlianafd May 05 '20 at 15:41
-
@Makdous can't be opened – berlianafd May 05 '20 at 15:41
3 Answers
1
you can use java.lang.Math.exp() method to calculate e^x. here is an example
`
public static void main(String[] args)
{
double a = 2.0;
System.out.println(Math.exp(a));
}
//output = 7.38905609893065
`
you can read more about this using this link. https://www.javatpoint.com/java-math-exp-method

Nuwan Harshakumara Piyarathna
- 212
- 5
- 14
0
You could use Math.exp().
Example:
import java.lang.Math;
// inside main
Math.exp(1.0); // e^1
Math.exp(1.6); // e^1.6

Animesh Sahu
- 7,445
- 2
- 21
- 49
-1
import java.lang.Math;
class Answer {
// driver code
public static void main(String args[])
{
double a = 30;
double b = 2;
System.out.println(Math.pow(a, b));
a = 3;
b = 4;
System.out.println(Math.pow(a, b));
a = 2;
b = 6;
System.out.println(Math.pow(a, b));
}
//you can use Math.pow(e,x);

papaya
- 1,505
- 1
- 13
- 26

Arunoday kumar
- 1
- 4
-
You did a valid guess but OP was definitely looking for _exponential_ function `Math.exp(double x)` :) – Nowhere Man May 05 '20 at 13:51
-
If someone use Math.pow(a,b) to calculate e^x ,use Math.E as e.But Math.exp() method is more suitable for this. – Nuwan Harshakumara Piyarathna May 05 '20 at 14:52