What are some strategies to come up with exercises? Like many programming books, there are mathematics books which do not provide exercises. Although similar in theory, how can I come up with exercises that will help illuminate a subject? The difference here is that when I pick up a programming book, I generally have an application in mind for whatever subject it is. This is not necessarily true when I pick up a mathematics book because I am not sure what type of questions I should ask. For example, when I first saw the definition of a measure space, I was not sure what kind of questions I should ask myself so that I can get more intuition about the subject. It was not until I saw multiple examples and solved many exercises that I learned what sort of questions were investigated in the book I read. Gaining such a skill where I could take a definition and extrapolate meaning is something I strongly desire. Is this sort of skill something that everyone learns as they gain more mathematical maturity, in a natural fashion, or is this something that has to be sought out?
 A: Designing good exercises is a kind of an art and certainly some authors are more skilled at it than others. Just like any other skill, it is honed be experience and improves with age. 
Exercises serve different purposes. Some exercises are meant to force the reader to battle with a definition. For instance, asking the reader to show that one axiomatization of a concept (say a group) is equivalent to another axiomatization will force the reader to really understand the axioms, think about them, and use them. Other exercises are aiming at making the reader proficient with a technique (computation technique or proof technique). For instance, exercises asking the reader to compute the determinant of a matrix or to prove an assertion by a straightforward induction. Some exercises are designed to be solved by mimicking the proof of a similar result given in the book, where that proof may be difficult or technically involved or other-wise a bit tricky. This forces the reader to really understand the proof and learn how to adapt it to prove similar results. An example would be to ask the reader to prove that the trace of a matrix is well-defined on similarity classes after seeing that the determinant has the same property. 
At a more holistic level are the exercises that aim at illuminating a global property of a theory or some large scale similarity with with other theories. For instance, a series of exercises that illustrate the interplay between matrices and linear transformations. And then there are also the "a-ha" exercises. Exercises that are easily solved as soon as you realize just that right theorem or conept that just kills it. For instance, proving that the Van Dermonde matrix is non-zero becomes crystal clear one the connection with polynomials is made, using a simple property of polynomials. One more type of exercises is those that aim at illustrating subtle difference that the reader might not expect. For instance, the different behaviour between finite dimension and infinite dimensional vector spaces (e.g., prove that a linear transformation between finite dimensional vector spaces of the same diemsnion is injective if, and only if, it is surjective, while for infinite dimensional vector spaces this is not true). 
I'm sure I missed some other types of exercises out there. Anyways, when I design exercises (for whatever illustrative purpose) I try to first think of the main goal the section wants to achieve, and then I try to have a good mix of types of exercises. Then I try to think of exercises and for me they just surface up (unless I'm too tired). Of course it helps to have read plenty of books with exercises and to actually have worked through plenty of exercises.
