If $f(x)=\langle x,a\rangle e^{-\langle x, x\rangle} \ \forall x, a \in \Bbb{R}^{n}$, then prove that $f$ is of class $C^{1}$ and compute $f'(x)$ Let $f:\Bbb{R}^n\to\Bbb{R}$ be a function defined by
$$f(x) = \langle x, a \rangle e^{-\langle x, x\rangle}$$
$\forall x \in \Bbb{R}^n, \ a \in \Bbb{R}^{n}$.
Questions: I want to  


*

*Prove that $f$ is of class $C^{1}$  

*Compute $f'(x)$ for any $x\in\Bbb{R}^n$


I started by using definition:
Let $x, a, h \in\Bbb{R}^{n}$, then
\begin{align}
f(x+h)-f(x) &= \langle x + h, a \rangle e^{-\langle x+h, x+h \rangle} - \langle x, a\rangle e^{-\langle x, x \rangle} \\
&= \left[ \langle x, a \rangle + \langle h, a \rangle \right] e^{-\langle x, x \rangle - \langle x, h \rangle - \langle h, x \rangle - \langle h, h \rangle} - \langle x, a \rangle e^{-\langle x, x \rangle}
\end{align}
But I don't know how to proceed from here. Please, could anyone help out?
 A: As you've written \begin{align}
f(x+h)-f(x) &= \langle x + h, a \rangle e^{-\langle x+h, x+h \rangle} - \langle x, a\rangle e^{-\langle x, x \rangle} \\
&= \left[ \langle x, a \rangle + \langle h, a \rangle \right] e^{-\langle x, x \rangle - \langle x, h \rangle - \langle h, x \rangle - \langle h, h \rangle} - \langle x, a \rangle e^{-\langle x, x \rangle}\\&=e^{-\langle x,x\rangle}\left(\langle x, a \rangle \left[e^{-2\langle x,h \rangle-\langle h,h\rangle}-1\right]+\langle h,a\rangle e^{-2\langle x,h \rangle-\langle h,h\rangle}\right)
\end{align}
notice that $\langle x,x\rangle$ is constant and we can make $-2\langle x,h\rangle-\langle h,h\rangle$ and $\langle h,a\rangle$ arbitrarily near to zero therefore $f(x+h)-f(x)$ can be arbitrarily bounded by proper choice of $h$ (this argument can be made more precise later) therefore $f(x)$ is continuous. The same argument can help us prove the 1st-order partial differentiability of the function. To show the differentiability of $f(x)$ respect to $x_i$ we need to show that the following function $$(a_ix_i+C)e^{-x_i^2+D}$$is differentiable respect to $x_i$ where$$C=a_2x_2+\cdots +a_nx_n\\D=-x_2^2-\cdots -x_n^2$$but this is simple since both $e^{-x_i^2+D}$ and $a_ix_i+C$ are differentiable respect to $x_i$ so will be their multiplication which completes our proof on 1st-order differentiability. We know that $$f(x)=f(x_1,\cdots,x_n)=(x_1a_1+\cdots+x_na_n)e^{-x_1^2-\cdots-x_n^2}$$therefore $$\dfrac{\partial f}{\partial x_i}=a_ie^{-x_1^2-\cdots-x_n^2}-2x_i(x_1a_1+\cdots+x_na_n)e^{-x_1^2-\cdots-x_n^2}$$where we can write$$\nabla f(x)=\left(a-2\langle x,a\rangle x\right)e^{-\langle x,x\rangle}$$
A: Not only is $f$ is of class $C^{1}$ it is smooth: it has derivatives of all orders. This follows from the fact that compositions of smooth maps are smooth. To find the derivative if $f$ is is enough to compute its partial derivatives. [ The derivative is a linear map from $\mathbb R ^{n} \to \mathbb R$ and its matrix is simply the vector of partial derivatives]. Computation of partial derivatives is very easy so I will leave that to you.
A: $\newcommand{\<}{\langle}\newcommand{\>}{\rangle}$I think you want to show differentiability using the definition, right? What is the definition of differentiability? $f$ is said to be differentiable in $x$, if there exists $L(x)$ such that as $h\to 0$:
\begin{align}\tag{1}
f(x+h)=f(x)+\<L(x), h\>+o(h)
\end{align}
Moreover if such $L$ exists then $\nabla f(x)=L(x)$. 
First notice that:
\begin{align}e^{-\<x+h,x+h \>}&=e^{-\<x,x\>-2\<x,h\>-\<h,h \>}\\
&=e^{-\<x,x\>}\left( e^{-2\<x,h\>-\<h,h \>}\right)\\
&\stackrel{*}{=}e^{-\<x,x\>}\left(1-2\<x,h\>-\<h,h \>+o(h)\right)\\
&=e^{-\<x,x\>}-2\<x,h\>e^{-\<x,x\>}+o(h)
\end{align}
where we have used the power series of the exponential function in $(*)$ which will be proven at the end. This means that:
\begin{align}
f(x+h)&=\<x+h,a\>e^{-\<x+h,x+h \>}\\&=\<x+h,a\>\left(e^{-\<x,x\>}-2\<x,h\>e^{-\<x,x\>}+o(h)\right)\\
&=\left(\<x,a\>+\<h,a\>\right)\left(e^{-\<x,x\>}-2\<x,h\>e^{-\<x,x\>}+o(h)\right)\\
&=\<x,a\>e^{-\<x,x\>}-2\<x,a\>\<x,h\>e^{-\<x,x\>}+\<h,a\>e^{-\<x,x\>}+o(h)\\
&=f(x)+e^{-\<x,x\>}\left( \< h,a\>-2\<x,a\>\<x,h\>\right)+o(h)\\
&=f(x)+ \< h,\left(a-2\<x,a\>x\right)e^{-\<x,x\>}\>+o(h)\\
\end{align}
Comparing what we have now with $(1)$ it is clear that $L(x)$ exists, hence:
\begin{align}
\nabla f(x)=\left(a-2\<x,a\>x\right)e^{-\<x,x\>}
\end{align}
Using a similar method, you can show that $\nabla f(x+h)\to\nabla f(x)$ as $h\to 0$ to conclude that $\nabla f$ is continuous... Or you could also check if $\nabla f(x)$ is continuous componentwise (because that implies continuity of $\nabla f$ as well). I leave that up to you.

Proof of ($*$).
\begin{align}
e^{-2\<x,h\>-\<h,h\>} = \sum_{k=0}^\infty \frac{(-2\<x,h\>-\<h,h\>)^k}{k!}=1-2\<x,h\>-\<h,h\>+\sum_{k=2}^\infty \frac{(-2\<x,h\>-\<h,h\>)^k}{k!}
\end{align}
Let $h\in \bar B_1(0)$ i.e. the closed unit ball. Then of course the map  $$h\mapsto -2\<x,h\>-\<h,h\>$$ is bounded (why?). That means that 
\begin{align}
\sum_{k=2}^\infty \frac{(-2\<x,h\>-\<h,h\>)^k}{k!}
\end{align}
converges uniformly for $h\in \bar B_1(0)$. So you can prove that:
\begin{align}
\lim_{h\to 0 } \frac{\sum_{k=2}^\infty \frac{(-2\<x,h\>-\<h,h\>)^k}{k!}}{\Vert h\Vert} =\sum_{k=2}^\infty \lim_{h\to 0 }\frac{(-2\<x,h\>-\<h,h\>)^k}{\Vert h\Vert k!}= 0
\end{align}
to conclude:
\begin{align}
\sum_{k=2}^\infty \frac{(-2\<x,h\>-\<h,h\>)^k}{k!}= o(h)
\end{align}
A: Lets express $f$ as explicitly;
$$f(x_1,...,x_n) = [x_1*a_1 + x_2*a_2 + ... + x_n * a_n] * e^{-x_1^2} * e^{-x_2^2} * ... * e^{-x_n^2}.$$
Now, for each variable $x_i$, $f$ has the form
$$f(x_1,...,x_n) = [x_i*a_i + c_1] * e^{-x_i^2} * c_2,\quad \text{for some constants } c_1,c_2 \in \mathbb{R}.$$
It is clear that since $f$ is a product of degree 1 polynomial with the exponential function, each of which is class of $C^\infty$, $f$ is also of class $C^\infty$.
Now, to find $\frac{\partial f}{\partial x_i}$, from the above representation of $f$, it is clear that
$$\frac{\partial f}{\partial x_i}|_{(x_1, ...,x_n)} = a_i * c_2 * e^{-x_i^2} + [x_i*a_i + c_1] * c_2 * (-2 x_i) * e^{-x_i^2} \\
= a_i * [\prod_{j=1}^n e^{-x_j^2}] + [x_i*a_i + c_1] * [\prod_{j=1}^n e^{-x_j^2}]*(-2 x_i)$$
