Invalid Value Encountered In Scalar Remainder Theorem