In the first, the second value is multipled by time.
double x = (speed.module * speed.direction.x()) + ((acceleration.module-Ambient.friction) * acceleration.direction.x())*time;
For the other, the whole thing is multiplied by time:
double x = ((speed.module * speed.direction.x()) + ((acceleration.module-Ambient.friction) * acceleration.direction.x()))*time;
This makes me think you are overflowing the double values in the second one before you multiple with time. With double overflow you get the magic values Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY
Most likely you are multiplting time with Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY and the result is NAN.
Change the calculations to a series of steps. With each step, check the result for overflow, by looking for Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY. That will tell you where things go off the rails. You are almost certainly overflowing somewhere, but we cannot see the numbers you are handling so I cannot tell you exactly where.