在Java的公式中使用电子

问题描述 投票:0回答:3

I'm trying to write a Java program that can take values and put them into a formula involving electron. How can I calculate e^x in Java?

java algorithm physics logarithm
3个回答
0
投票

import java.lang.Math;

班级答案{

// 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)); 
} 

//您可以使用Math.pow(e,x);


0
投票

您可以使用java.lang.Math.exp()方法来计算e ^ x。这是一个例子

`
public static void main(String[] args) 
{
    double a = 2.0;
    System.out.println(Math.exp(a));
}
//output = 7.38905609893065
`

您可以使用此链接阅读有关此内容的更多信息。https://www.javatpoint.com/java-math-exp-method


0
投票

您可以使用Math.exp()

示例:

import java.lang.Math;

// inside main
Math.exp(1.0);        // e^1
Math.exp(1.6);        // e^1.6
© www.soinside.com 2019 - 2024. All rights reserved.