Subgradient example Let $f(x_1, x_2)$ be defined as:
if $x_1 =0$ then $f(x_1,x_2)=x^2_2$
else $\infty$
The subgradient of $f(x_1,x_2)$ at $(0,0)$ is given as:
$\mathbf{R} \times \{0\}$. (The real line crossed with 0).
How is this determined?  I can see that when $x_1=0$, $\nabla f(x_1,x_2)=(0,2x_2)$; so at $(0,0)$, we have a slope of $1$.  But where does the "$\mathbf{R}$" part come from?

According to the definition of a subgradient that I know (referenced http://web.stanford.edu/class/ee392o/subgrad.pdf and on Wikipedia), a subgradient is not a set, but rather a vector (or a scalar in the case where $f:\mathbb{R}\rightarrow\mathbb{R}$).  So, according to these definitions, any element of $\mathbb{R}\times\{0\}$ is a subgradient of your $f$.  The set of all subgradients is called the subdifferential.  So $\mathbb{R}\times\{0\}$ is the subdifferential of $f$ at $(0,0)$.
Having said that, a subgradient at x is any vector that satisfies $f(y) \geq f(x) + g^T(y-x)$.  You can check that any vector from your set satisfies this property.
Intuitvely, we can think of it as the slope of any line that completely lies below the graph.  And which lines do that?  If the domain we're interested in is the line $x_2=0$ then we have a regular derivative, and we see that the slope of the function must be $0$.  This tells us that the second component of the subgradient (which is a two element vector in your case) must be 0.  How about the first component?  Since the function "is" $\infty$ at all other points, any slope will do.
Imagine you have a solid slab of marble.  And someone has made a pipe that lies along the function $f(x_1,x_2)=x_2^2$.  You want to place the slab at below the pipe $(0,0)$.  What can the gradient of that slab be at $(0,0)$?  It has to be flat in the $x_2$ direction, but you can make it as steep as you want in the $x_1$ direction.
I hope this helps.
