I would like to calculate the exponential values of the elements of a list / vector. For example, I would like to calculate the Boltzmann distribution over different energy levels where the normalized population of the energy level, $N_i$, is calculated using the energy of those levels, $E_i$, and temperature($T$) as:
$$N_i= \frac{\exp(-\frac{E_i}{T})}{\sum {\exp(-\frac{E_i}{T})}} $$
Exp[E] doesn’t work if E is a vector. I guess I can calculate element by element for each $N_i$ using a loop for all i in an E[[i]], but in most language, there is a way to vectorize functions (function acting on a vector elementwise), which are generally way faster and nicer. What is the recommended “Mathematical” way to do this?
Edit: Thank you everyone for the help. It turned out I had a stupid mistake ( 11i think a 0/0 somewhere inside the vector) that is why Exp[] didn't work on a vector.
Exp
automatically thread over lists element-wise. For example:Exp[Range[5]]
. Is that not what you need? $\endgroup$E
as a symbol, it's predefined! $\endgroup$