solve the problem when calculate the function result is NAN