multidimensional chain rule, example Given $f:\mathbb{R}^3\to\mathbb{R}$, $f(u,v,w)=uv+vw-uw$ and
$g:\mathbb{R}^2\to\mathbb{R}^3$, $g(x,y)=(x+y, x+y^2, x^2+y)$, I have to give $D(f\circ g)(x,y)$
I calculated like this:
$Df(u,v,w)=(v-w, u+w, v-u)$ and
$Dg(x,y)=\begin{pmatrix} 1&1&2x\\ 1&2y& 1\\ 0&0&0\end{pmatrix}$
Furthermore it is $Df(g(x,y))=(x+y^2-x^2-y, x+y+x+y^2, x+y^2-x-y)$
Now with the multidimensional chain rule, we have:
$D(f\circ g)(x,y)=Df(g(x,y))\cdot Dg(x,y)$
$(y^2-x^2+x+y, y^2+y+2x, y^2-y)\cdot\begin{pmatrix} 1&1&2x\\ 1&2y& 1\\ 0&0&0\end{pmatrix}$
$$=(\color{red}{y^2-x^2+x-y+y^2+y+2x}, \color{blue}{y^2-x^2+x-y+2y^3+2y^2+2xy}, \color{orange}{2xy^2-2x^3+2x^2-2xy+y^2+y+2x})$$
$$=(\color{red}{2y^2+3x-x^2}, \color{blue}{2y^3+3y^2-y-x^2+x+4xy}, \color{orange}{y^2+y-2x^3+2x^2+2x+2xy^2-2xy})$$
Which is wrong accoring to:
http://www.wolframalpha.com/input/?dataset=&i=d%2Fdx+ReplaceAll%5Buv%2Bvw-uw,%7Bu-%3Ex%2By,v-%3Ex%2By%5E2,w-%3Ex%5E2%2By%7D%5D
[You might check Multidimensional chain rule, online calculator for further reference.]
But I do not see my mistake myself, unfortunatly.
Also I have a question, because I got a little bit confused by the notation.
If you write $g:\mathbb{R}^2\to\mathbb{R}^3$, $g(x,y)=(x+y, x+y^2, x^2+y)$, dont you have to be more clear and note $(x+y, x+y^2, x^2+y)^t$, since a vector in $\mathbb{R}^3$ should be normally noted like $\begin{pmatrix}x\\y\\z\end{pmatrix}$ this [where I just use $x,y,z$ because of simplicity], or do I mess something up here?
Thanks in advance.
 A: $Dg(x,y)$ should be a matrix of $3\times 2$.
A: We have the composition $f(u(x,y),v(x,y),w(x,y)).$ Then it is
$$\dfrac{\partial f}{\partial x}=\dfrac{\partial f}{\partial u}\dfrac{\partial u}{\partial x}+\dfrac{\partial f}{\partial v}\dfrac{\partial v}{\partial x}+\dfrac{\partial f}{\partial w}\dfrac{\partial w}{\partial x}$$ and 
$$\dfrac{\partial f}{\partial y}=\dfrac{\partial f}{\partial u}\dfrac{\partial u}{\partial y}+\dfrac{\partial f}{\partial v}\dfrac{\partial v}{\partial y}+\dfrac{\partial f}{\partial w}\dfrac{\partial w}{\partial y}.$$ This can be written as a product of matrices as
$$\begin{pmatrix} \dfrac{\partial f}{\partial x}\\ \dfrac{\partial f}{\partial y}\end{pmatrix}=\begin{pmatrix} \dfrac{\partial f}{\partial u} &\dfrac{\partial f}{\partial v}&\dfrac{\partial f}{\partial w}\end{pmatrix} \begin{pmatrix} \dfrac{\partial u}{\partial x} &\dfrac{\partial u}{\partial y}\\ \dfrac{\partial v}{\partial x} &\dfrac{\partial v}{\partial y}\\\dfrac{\partial w}{\partial x} &\dfrac{\partial u}{\partial w}\end{pmatrix}.$$
That is 
$$\begin{pmatrix} \dfrac{\partial f}{\partial x}\\ \dfrac{\partial f}{\partial y}\end{pmatrix}=\begin{pmatrix}x-x^2+y^2-y, & x+x^2+2y, &y^2-y\end{pmatrix}\begin{pmatrix} 1&1\\1&2y\\2x&1\end{pmatrix} $$ and we get
$$\begin{pmatrix} \dfrac{\partial f}{\partial x}\\ \dfrac{\partial f}{\partial y}\end{pmatrix}= \begin{pmatrix} 2x(y^2-y+1)+y(y+1)\\ x^2(2y-1)+2xy+x+2y(3y-1)\end{pmatrix}.$$
