The vectorized solution for computing the cost function using the numpy library.