derivative of a function with nested square roots