vivek patel
vivek patel

Reputation: 63

exponential method in java

I am performing some mathematical calculation like exponential but here I am getting some thing wrong in X3 and X4...it is printing value 0... even when X1 and X2 has some value X3 and X4 are printed as 0. Is this correct method for finding exponential? Please tell me where is the problem?

X=1/(standarddeviation*Math.sqrt(2*3.14159));
X1=((balance1-MEAN)/standarddeviation);
// System.out.println("x1 ="+X1);
X10=Math.pow(X1, 2);
System.out.println("x1 ="+X10);
X2=((-0.5)*X10);
System.out.println("x2 ="+X2);
// X3=Math.pow(X2, 2.7183);
X3=Math.exp(X2);
System.out.println("x3 ="+X3);
X4=X3*X;
System.out.println("x4 ="+X4);

Upvotes: 0

Views: 271

Answers (1)

Anakar
Anakar

Reputation: 112

I dont know if this will solve your purpose. But I tried to compute the values and came to the following conclusion

If X2 is negative infinity, then the result is positive zero which in your case is X3.

If you go see the javadocs for Math.exp function in java then its mentioned there. Link - http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html

For your example I have tried to put sample values and I got the similar result

public static void main(String args[]){
        double X10=Math.pow(-34531, 2);
        System.out.println("X10 : " + X10);
        double X2=((-0.5)*X10);
        System.out.println("X2 : " + X2);
        double X3=Math.exp(X2);
        System.out.println("X3 : " + X3);
    }

Output :

X10 : 1.192389961E9
X2 : -5.961949805E8
X3 : 0.0

Upvotes: 1

Related Questions