I’m having an issue with a particularly lengthy mathematical function.
The function is e^(-x^2) + 1, coded as
(float)(Math.exp(Math.pow(evalPoint, 2.0) * -1) + 1); because I need it returned to me as a float.
I implemented this equation in a static method within my main program and I was getting the right answer for my test points.
The problem arose when I moved this function out into another class as part of an interface implementation. Now when I test the function I’m getting answers that are way off what they should be. When evaluating this equation at x=2, the proper answer is 1.01, but through the interface I’m getting an answer of 2.41.
Anyone know what the issue may be? Could it possibly be an issue with the fact that Math.pow and Math.exp normally take doubles but I’m passing in floats and then casting to a float for the final answer?
Any help would be greatly appreciated!