How to find the mins and max for different situations. Using the derivative to find critical points and solving for all values