Reputation: 57
I have this expression:
(0.8733 * (Math.atan((0.375 ^ 1.75) * -2.1855))) + 1)
and the result I expect is 0.673183
. Wolfram alpha gets it right when I copy+paste the equation into there (replacing Math.atan with arctan)
(0.8733 * (arctan((0.375 ^ 1.75) * -2.1855))) + 1)
But Javascript gives me this result:
0.002977558258926538
It's been a while since math class, but I believe there are different ways of expressing the result, so maybe I am getting one out ot Javascript when I expect the other? Or maybe something else is wrong, but I am not sure how to debug this.
What do I need to do differently to get the expected result? Ultimately I want to replace two of these numbers (0.375 and 1.75) with variables to get results along this line of this graph but due to this unexpected result my expression is not mimicking the graph.
Upvotes: 0
Views: 65
Reputation: 2909
You use ^
-Operator in Javascript, which is not the power (which is Math.pow
) but the binary XOR
-Operator. I think this is not what you intended. Try
(0.8733 * (Math.atan(Math.pow(0.375, 1.75) * -2.1855))) + 1)
Upvotes: 2