exercise 5 with linear regression cost & gradient