Differentiation of $f(x_1, x_2) = \frac{x_1^2 + x_2^2}{x_2 - x_1 + 2}$ this question might sound stupid to you, but I am having problems right now to differentiate this function:
$$f(x_1, x_2) = \frac{x_1^2 + x_2^2}{x_2 - x_1 + 2}$$
I know the solution, from wolfram alpha, however I do not know how to come up with it by my own. 
I would appreciate your answer, if you could show me how to differentiate by $x_1$?
 A: When you take partial derivatives you have to be consider all variables constant, except the one that you are differentiating in respect with. To do this, what you can do to begin with, is fix some of the variables with some constant name. In your case, write
$$f(x_1,a)=\dfrac{x_1^2+a^2}{a-x_1+2},$$
your variable is $x_1$, so you differentiate using the standard differentiation rules you know from single variable calculus
$$D_1f(x_1,a)=\dfrac{2x_1(a-x_1+2)+(x_1^2+a^2)}{(a-x_1+2)^2}.$$
This is true for every $a$, so you can define a function $D_1f$ in $\mathbb{R}^2$ by setting
$$D_1f(x_1,x_2)=\dfrac{2x_1(x_2-x_1+2)+(x_1^2+x_2^2)}{(x_2-x_1+2)^2}$$
and there you have your derivative. This step of renaming the other variables to constant is just done when one is beginning, usually we go straight to the last step here.
A: Consider $$f(x_1,x_2)={x_1^2+x_2^2\over x_2-x_1+2}.$$ Take the derivative with respect to $x_1$ and treat $x_2$ as a constant. So $${\partial f(x_1,x_2)\over \partial x_1}={{\partial\over \partial x_1}[(x_1^2+x_2^2)]\cdot(x_2-x_1+2)-(x_1^2+x_2^2)\cdot{\partial \over \partial x_1}[(x_2-x_1+2)]\over (x_2-x_1+2)^2}.$$ This gives us $${\partial f(x_1,x_2)\over \partial x_1}={2x_1(x_2-x_1+2)-(x_1^2+x_2^2)(-1)\over (x_2-x_1+2)^2}.$$ Distributing we obtain $${\partial f(x_1,x_2)\over \partial x_1}={-x_1^2+2x_1(x_2+2)+x_2^2\over (x_2-x_1+2)^2}.$$
A: You need to use the definition of partial derivative, before getting used to sentences like "treat $x_2$ as constant". Let us do it:
$$\frac{\partial f}{\partial x_1}(x_1,x_2):=\lim_{t\rightarrow 0}\frac{f(x_1+t,x_2)-f(x_1,x_2)}{t}=\lim_{t\rightarrow 0}\frac{(x_1^2+x_2^2)(x_2-x_1+2)-(x_1^2+x_2^2)(x_2-x_1+2)+t(2x_1+t)(x_2-x_1+2)+t(x_1^2+x_2^2)}{t(x_2-x_1-t+2)(x_2-x_1+2)}=
\\\lim_{t\rightarrow 0}\frac{(2x_1+t)(x_2-x_1+2)+(x_1^2+x_2^2)}{(x_2-x_1-t+2)(x_2-x_1+2)}=\frac{2x_1(x_2-x_1+2)+(x_1^2+x_2^2)}{(x_2-x_1+2)^2},$$
which is the desired result.
