Click to See Complete Forum and Search --> : Java Math


KingCobra220
03-05-2006, 12:00 AM
I got two formulas, in PHP, from a friend that I want to use in Java. Here are the formulas:
x, y, and z are all doubles.

z=(pow(M_E,((x/100)-sqrt(log(y+1))))-1);
y=pow(M_E,pow((x/100)-log(z+1),2));

I tried to convert it and got this...

z = (Math.pow(Math.E,((x / 100) - Math.sqrt(Math.log(y + 1)))) - 1);
y = (Math.pow(Math.E,Math.pow((x / 100) - Math.log(z + 1),2)));


I don't get any compile errors but when I try to run some numbers through the formulas, I get one of those dos window errors (excuse the lack of proper terminology). I obviously didn't convert to Java correctly. Does anyone know how to fix my problem? Thanks a bunch.

crazycoder
03-05-2006, 12:04 PM
It looks like you have an extra ) on the end of
y = (Math.pow(Math.E,Math.pow((x / 100) - Math.log(z + 1),2)));

KingCobra220
03-05-2006, 12:16 PM
It looks like you have an extra ) on the end of
y = (Math.pow(Math.E,Math.pow((x / 100) - Math.log(z + 1),2)));

I actually just tried adding a pair of '()' and got one of the formulas to work. Thanks for the help.