Derivative of $f(x,y)=x-y$, where $x,y\in\mathbb R^2$ 
Suppose that $f:\mathbb R^2\times\mathbb R^2\to\mathbb R^2$ is given by $f(x,y)=x-y$. How can I calculate the first and the second order derivative of $f$?

If $g:\mathbb R^n\to\mathbb R$, the gradient vector and the Hessian matrix of $g$ are given by
$$
\nabla g(x)_i=\frac{\partial g(x)}{\partial x_i}
\quad\text{and}\quad
\nabla^2g(x)_{ij}=\frac{\partial^2g(x)}{\partial x_i\partial x_j}
$$
for $i,j=1,\ldots,n$. But the function $f$ is defined on the Cartesian product $\mathbb R^2\times\mathbb R^2$. Is the Cartesian product $\mathbb R^2\times\mathbb R^2$ the same as $\mathbb R^4$ in some sense?
Any help is much appreciated!
 A: Use the definition: Fix $(x_,y)\in \mathbb R^2\times \mathbb R^2.$ You are looking for a linear transformation $T(x,y):\mathbb R^2\times \mathbb R^2\to \mathbb R^2$ that satisfies the property
$\tag1 f(x+h,y+k)=f(x,y)+T(x,y)(h,k)+r(h,k)\ \text{where}\ \frac{|r(h,k)|}{|(h,k)|}\to 0\ \text{as}\  (h,k)\to 0.$
It is easy to show that if $T(x,y)$ exists, it is unique, so all we have to do is find one such that satisfies $(1)$.
Set $T(x,y)(h,k)=h-k$ and substitute into $(1)$. After rearranging, we get 
$r(h,k)=x+h-(y+k)-(x-y)-(x-y)-(h-k)=0$ so in fact, $T(x,y)$ satisfies $(1)$ so we have found our derivative. That is, 
$\tag2 Df(x,y)=T(x,y)$
Notice that it is no harder to show in general that if $f$ is already linear, then its derivative is itself. 
For the second derivative, we note that what $(2)$ says is that $Df$ is a function from $\mathbb R^2\times \mathbb R^2$ into $L(\mathbb R^2\times \mathbb R^2,\mathbb R^2).$ Therefore, $DDf(x,y)$ is the linear function that sends $(h,k)$ to a linear transformation $\mathbb R^2\times \mathbb R^2\to \mathbb R^2$ that satisfies
$\tag3 Df(x+h,y+k)=Df(x,y)+(DDf)(x,y))(h,k)+r(h,k)$
$$\text{where}\ \frac{|r(h,k)|}{|(h,k)|}\to 0\ \text{as}\  (h,k)\to 0.$$
Set $DDf(x,y)(h,k)=Df(x,y).$ Then, calculating as above, evaluating each term on $(h_1,k_1),$ we get
$\tag4 r(h,k)(h_1,k_1)=Df(x+h,y+k)(h_1,k_1)-Df(x,y)(h_1,k_1)-(DDf)(x,y))(h,k)(h_1,k_1)=0-(h_1-k_1)\to 0$ 
$$\text{as}\ |(h_1,k_1)|\to 0$$
and so again, we have found the second derivative because our choice satisfies the condition of the formula. 
A: As you can see, $f$ is not in the form of $\mathbb{R}^n \to \mathbb{R}$, so that definitions won't work. So what does the "first-order and second-order derivative" mean for you?
One option is to look at $(\mathbb{R}^2 \times \mathbb{R}^2, ||.||_1)$ and $(\mathbb{R}^2, ||.||_2)$ as normed spaces (with your favorite norms on them), and look at the Fréchet derivative of $f$.
