derivative using chain rule with natural log and cosine